]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/message.c
Remove SQLite2 scripts
[bacula/bacula] / bacula / src / lib / message.c
index d9abff3bcc8c2a7d921416006a4088aecd9672db..5791f6b51b95a43be565ad351630d7e48dd24029 100644 (file)
@@ -48,6 +48,7 @@ const char *working_directory = NULL;       /* working directory path stored her
 int verbose = 0;                      /* increase User messages */
 int debug_level = 0;                  /* debug level */
 bool dbg_timestamp = false;           /* print timestamp in debug output */
+bool prt_kaboom = false;              /* Print kaboom output */
 utime_t daemon_start_time = 0;        /* Daemon start time */
 const char *version = VERSION " (" BDATE ")";
 char my_name[30];                     /* daemon name is stored here */
@@ -479,7 +480,7 @@ void close_msg(JCR *jcr)
             if (msgs != daemon_msgs) {
                /* read what mail prog returned -- should be nothing */
                while (fgets(line, len, bpipe->rfd)) {
-                  Jmsg1(jcr, M_INFO, 0, _("Mail prog: %s"), line);
+                  Qmsg1(jcr, M_INFO, 0, _("Mail prog: %s"), line);
                }
             }
 
@@ -488,7 +489,7 @@ void close_msg(JCR *jcr)
                berrno be;
                be.set_errno(stat);
                Dmsg1(850, "Calling emsg. CMD=%s\n", cmd);
-               Jmsg2(jcr, M_ERROR, 0, _("Mail program terminated in error.\n"
+               Qmsg2(jcr, M_ERROR, 0, _("Mail program terminated in error.\n"
                                         "CMD=%s\n"
                                         "ERR=%s\n"), cmd, be.bstrerror());
             }
@@ -638,6 +639,7 @@ void dispatch_message(JCR *jcr, int type, utime_t mtime, char *msg)
        fputs(dt, stdout);
        fputs(msg, stdout);         /* print this here to INSURE that it is printed */
        fflush(stdout);
+       syslog(LOG_DAEMON|LOG_ERR, "%s", msg);
     }
 
 
@@ -1356,10 +1358,9 @@ void Qmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...)
    if (!jcr) {
       jcr = get_jcr_from_tsd();
    }
-   /* If no jcr or no queue send to daemon */
-   if ((jcr && !jcr->msg_queue) || !jcr) {
-      /* jcr==NULL => daemon message, safe to send now */
-      Jmsg(jcr, item->type, item->mtime, "%s", item->msg);
+   /* If no jcr or no queue or dequeuing send to syslog */
+   if (!jcr || !jcr->msg_queue || jcr->dequeuing_msgs) {
+      syslog(LOG_DAEMON|LOG_ERR, "%s", item->msg);
       free(item);
    } else {
       /* Queue message for later sending */
@@ -1380,11 +1381,13 @@ void dequeue_messages(JCR *jcr)
       return;
    }
    P(jcr->msg_queue_mutex);
+   jcr->dequeuing_msgs = true;
    foreach_dlist(item, jcr->msg_queue) {
       Jmsg(jcr, item->type, item->mtime, "%s", item->msg);
    }
    /* Remove messages just sent */
    jcr->msg_queue->destroy();
+   jcr->dequeuing_msgs = false;
    V(jcr->msg_queue_mutex);
 }