]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix auto-debug logging of job errors with systemd (Issue #5337)
authorMichael R Sweet <michael.r.sweet@gmail.com>
Tue, 19 Jun 2018 01:46:55 +0000 (21:46 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Tue, 19 Jun 2018 01:46:55 +0000 (21:46 -0400)
CHANGES.md
scheduler/log.c

index 5bc5e9f836dbb17409b6ba6038e3b4dc46ec2fbf..d31c1601f71a358bbe09cd1bf56f43c5443b29a2 100644 (file)
@@ -12,6 +12,7 @@ Changes in CUPS v2.2.9
 - Fixed a regression in the changes to ippValidateAttribute (Issue #5322,
   Issue #5330)
 - Fixed a crash bug in the Epson dot matrix driver (Issue #5323)
+- Automatic debug logging of job errors did not work with systemd (Issue #5337)
 - The web interface did not list the IPP Everywhere "driver" (Issue #5338)
 - Fixed a memory leak for some IPP (extension) syntaxes.
 
index 1b94a5066f8005be12ed4bab7698d4884a46f3dd..bab918769425853d20c2a46ba3b4746fc3cd27cb 100644 (file)
@@ -568,56 +568,15 @@ cupsdLogJob(cupsd_job_t *job,             /* I - Job */
   if (level > LogLevel && LogDebugHistory <= 0)
     return (1);
 
-#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
-  if (!strcmp(ErrorLog, "syslog"))
-  {
-    cupsd_printer_t *printer = job ? (job->printer ? job->printer : (job->dest ? cupsdFindDest(job->dest) : NULL)) : NULL;
-    static const char * const job_states[] =
-    {                                  /* job-state strings */
-      "Pending",
-      "PendingHeld",
-      "Processing",
-      "ProcessingStopped",
-      "Canceled",
-      "Aborted",
-      "Completed"
-    };
-
-    va_start(ap, message);
-
-    do
-    {
-      va_copy(ap2, ap);
-      status = format_log_line(message, ap2);
-      va_end(ap2);
-    }
-    while (status == 0);
-
-    va_end(ap);
-
-    if (job)
-      sd_journal_send("MESSAGE=%s", log_line,
-                     "PRIORITY=%i", log_levels[level],
-                     PWG_Event"=JobStateChanged",
-                     PWG_ServiceURI"=%s", printer ? printer->uri : "",
-                     PWG_JobID"=%d", job->id,
-                     PWG_JobState"=%s", job->state_value < IPP_JSTATE_PENDING ? "" : job_states[job->state_value - IPP_JSTATE_PENDING],
-                     PWG_JobImpressionsCompleted"=%d", ippGetInteger(job->impressions, 0),
-                     NULL);
-    else
-      sd_journal_send("MESSAGE=%s", log_line,
-                     "PRIORITY=%i", log_levels[level],
-                     NULL);
-
-    return (1);
-  }
-#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
-
  /*
   * Format and write the log message...
   */
 
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
+  if (job && strcmp(ErrorLog, "syslog"))
+#else
   if (job)
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
     snprintf(jobmsg, sizeof(jobmsg), "[Job %d] %s", job->id, message);
   else
     strlcpy(jobmsg, message, sizeof(jobmsg));
@@ -676,7 +635,43 @@ cupsdLogJob(cupsd_job_t *job,              /* I - Job */
       return (1);
     }
     else if (level <= LogLevel)
+    {
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
+      if (!strcmp(ErrorLog, "syslog"))
+      {
+       cupsd_printer_t *printer = job ? (job->printer ? job->printer : (job->dest ? cupsdFindDest(job->dest) : NULL)) : NULL;
+       static const char * const job_states[] =
+       {                                       /* job-state strings */
+         "Pending",
+         "PendingHeld",
+         "Processing",
+         "ProcessingStopped",
+         "Canceled",
+         "Aborted",
+         "Completed"
+       };
+
+       if (job)
+         sd_journal_send("MESSAGE=%s", log_line,
+                         "PRIORITY=%i", log_levels[level],
+                         PWG_Event"=JobStateChanged",
+                         PWG_ServiceURI"=%s", printer ? printer->uri : "",
+                         PWG_JobID"=%d", job->id,
+                         PWG_JobState"=%s", job->state_value < IPP_JSTATE_PENDING ? "" : job_states[job->state_value - IPP_JSTATE_PENDING],
+                         PWG_JobImpressionsCompleted"=%d", ippGetInteger(job->impressions, 0),
+                         NULL);
+       else
+         sd_journal_send("MESSAGE=%s", log_line,
+                         "PRIORITY=%i", log_levels[level],
+                         NULL);
+
+       return (1);
+      }
+      else
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
+
       return (cupsdWriteErrorLog(level, log_line));
+    }
     else
       return (1);
   }