]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/log.c
Stop advertising the HTTP methods that are supported (Issue #5540)
[thirdparty/cups.git] / scheduler / log.c
index 18d916f5f1ca7fd1690b768ff221cb632f1347d7..cdb5437dcf712ace4d0cdcd203bbfef5af4924b6 100644 (file)
@@ -1,10 +1,11 @@
 /*
  * Log file routines for the CUPS scheduler.
  *
- * Copyright 2007-2017 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright © 2007-2018 by Apple Inc.
+ * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
  *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more
+ * information.
  */
 
 /*
@@ -564,56 +565,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));
@@ -672,7 +632,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);
   }
@@ -956,7 +952,7 @@ cupsdLogPage(cupsd_job_t *job,              /* I - Job being printed */
   *bufptr = '\0';
 
 #ifdef HAVE_SYSTEMD_SD_JOURNAL_H
-  if (!strcmp(ErrorLog, "syslog"))
+  if (!strcmp(PageLog, "syslog"))
   {
     static const char * const job_states[] =
     {                                  /* job-state strings */
@@ -1046,7 +1042,7 @@ cupsdLogRequest(cupsd_client_t *con,      /* I - Request to log */
   * Filter requests as needed...
   */
 
-  if (AccessLogLevel == CUPSD_ACCESSLOG_NONE)
+  if (AccessLogLevel == CUPSD_ACCESSLOG_NONE || !AccessLog)
     return (1);
   else if (AccessLogLevel < CUPSD_ACCESSLOG_ALL)
   {