]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
scheduler/log.c: Use `[Job N]` even for syslog
authorZdenek Dohnal <zdohnal@redhat.com>
Fri, 19 Mar 2021 08:25:41 +0000 (09:25 +0100)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Thu, 25 Mar 2021 15:00:40 +0000 (11:00 -0400)
Currently there is a difference in job log format based on where logs
are sent - the message contains `[Job N]` if sent to a file and it
doesn't contain the string if sent to syslog.
Though it can be seen as a duplicate of information, since the main
syslog system used (journald) is capable of filtering messages based on
JID, but having `[Job N]` string in logs in syslog is useful when you
need to debug complex issues and you need to see what happens in the
scheduler and in a specific job at the same time - f.e. at print
servers.

How to reproduce:
0) set error logs to syslog in /etc/cups/cups-files.conf
1) $ cupsctl --debug-logging
2) $ lp -d <queue> <file>
3) $ journalctl -u cups

Actual results:
Cannot distinguish logs from scheduler and from the job

Results after the patch:
Job logs have `[Job N]` at the start of message, where N is a job id.

CHANGES.md
scheduler/log.c

index ebd260b1fde8482e752c9132999ca30d0cb2e6bd..9bb724a70e8a85aa2adac7a81d314d0cb861a6a7 100644 (file)
@@ -30,6 +30,7 @@ CUPS v2.4rc1 (Pending)
   and `cups-files.conf`.
 - Add `SYSTEMD_WANTED_BY` variable for adding different targets into 'WantedBy'
   directive in CUPS service file during configuration (Issue #144)
+- Log `Job N` even for syslog
 
 
 CUPS v2.3.3op2 (February 1, 2021)
index 17331ff02e761e6b49f68390ae52de4803993f99..41ddb4cb99978bb8f410c9fa4006e90383718e32 100644 (file)
@@ -569,11 +569,7 @@ cupsdLogJob(cupsd_job_t *job,              /* I - Job */
   * 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));