2018-06-27 14:21:32 +00:00
|
|
|
diff --git a/scheduler/log.c b/scheduler/log.c
|
|
|
|
index b6226201f..cdb5437dc 100644
|
|
|
|
--- a/scheduler/log.c
|
|
|
|
+++ b/scheduler/log.c
|
|
|
|
@@ -565,56 +565,15 @@ cupsdLogJob(cupsd_job_t *job, /* I - Job */
|
|
|
|
if (level > LogLevel && LogDebugHistory <= 0)
|
2018-06-12 10:12:20 +00:00
|
|
|
return (1);
|
|
|
|
|
2018-06-27 14:21:32 +00:00
|
|
|
-#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
|
2018-06-12 10:12:20 +00:00
|
|
|
- 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);
|
|
|
|
- }
|
2018-06-27 14:21:32 +00:00
|
|
|
-#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
|
|
|
|
-
|
2018-06-12 10:12:20 +00:00
|
|
|
/*
|
2018-06-27 14:21:32 +00:00
|
|
|
* 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));
|
|
|
|
@@ -673,7 +632,43 @@ cupsdLogJob(cupsd_job_t *job, /* I - Job */
|
2018-06-12 10:12:20 +00:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
else if (level <= LogLevel)
|
|
|
|
+ {
|
|
|
|
+#ifdef HAVE_SYSTEMD_SD_JOURNAL_H
|
|
|
|
+ if (!strcmp(ErrorLog, "syslog"))
|
|
|
|
+ {
|
2018-06-27 14:21:32 +00:00
|
|
|
+ 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);
|
2018-06-12 10:12:20 +00:00
|
|
|
+ }
|
2018-06-27 14:21:32 +00:00
|
|
|
+ else
|
2018-06-12 10:12:20 +00:00
|
|
|
+#endif /* HAVE_SYSTEMD_SD_JOURNAL_H */
|
2018-06-27 14:21:32 +00:00
|
|
|
+
|
2018-06-12 10:12:20 +00:00
|
|
|
return (cupsdWriteErrorLog(level, log_line));
|
|
|
|
+ }
|
|
|
|
else
|
|
|
|
return (1);
|
|
|
|
}
|