+#ifdef HAVE_ASL_H
+ if (!strcmp(ErrorLog, "syslog"))
+ {
+ asl_object_t m; /* Log message */
+ char job_id[32], /* job-id string */
+ completed[32]; /* job-impressions-completed string */
+ 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"
+ };
+
+ m = asl_new(ASL_TYPE_MSG);
+ asl_set(m, ASL_KEY_FACILITY, "org.cups.cupsd");
+ if (printer)
+ asl_set(m, PWG_ServiceURI, printer->uri);
+ if (job)
+ {
+ snprintf(job_id, sizeof(job_id), "%d", job->id);
+
+ asl_set(m, PWG_Event, "JobStateChanged");
+ asl_set(m, PWG_JobID, job_id);
+ asl_set(m, PWG_JobState, job->state_value < IPP_JSTATE_PENDING ? "" : job_states[job->state_value - IPP_JSTATE_PENDING]);
+
+ if (job->impressions)
+ {
+ snprintf(completed, sizeof(completed), "%d", ippGetInteger(job->impressions, 0));
+ asl_set(m, PWG_JobImpressionsCompleted, completed);
+ }
+ }
+
+ va_start(ap, message);
+ asl_vlog(NULL, m, log_levels[level], message, ap);
+ va_end(ap);
+
+ asl_release(m);
+ return (1);
+ }
+
+#elif defined(HAVE_SYSTEMD_SD_JOURNAL_H)
+ if (!strcmp(ErrorLog, "syslog"))
+ {
+ cupsd_printer_t *printer = job->printer ? job->printer : job->dest ? cupsdFindDest(job->dest) : 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_ASL_H */
+