diff -up cups-2.0rc1/conf/cups-files.conf.in.journal cups-2.0rc1/conf/cups-files.conf.in --- cups-2.0rc1/conf/cups-files.conf.in.journal 2014-03-03 17:46:23.000000000 +0100 +++ cups-2.0rc1/conf/cups-files.conf.in 2014-09-12 17:47:14.668190332 +0200 @@ -28,9 +28,10 @@ SystemGroup @CUPS_SYSTEM_GROUPS@ #ConfigFilePerm 0@CUPS_CONFIG_FILE_PERM@ #LogFilePerm 0@CUPS_LOG_FILE_PERM@ -# Location of the file logging all access to the scheduler; may be the name -# "syslog". If not an absolute path, the value of ServerRoot is used as the -# root directory. Also see the "AccessLogLevel" directive in cupsd.conf. +# Location of the file logging all access to the scheduler; may be the +# name "syslog" or "journal". If not an absolute path, the value of +# ServerRoot is used as the root directory. Also see the +# "AccessLogLevel" directive in cupsd.conf. AccessLog @CUPS_LOGDIR@/access_log # Location of cache files used by the scheduler... @@ -42,10 +43,10 @@ AccessLog @CUPS_LOGDIR@/access_log # Location of the static web content served by the scheduler... #DocumentRoot @CUPS_DOCROOT@ -# Location of the file logging all messages produced by the scheduler and any -# helper programs; may be the name "syslog". If not an absolute path, the value -# of ServerRoot is used as the root directory. Also see the "LogLevel" -# directive in cupsd.conf. +# Location of the file logging all messages produced by the scheduler +# and any helper programs; may be the name "syslog" or "journal". If +# not an absolute path, the value of ServerRoot is used as the root +# directory. Also see the "LogLevel" # directive in cupsd.conf. ErrorLog @CUPS_LOGDIR@/error_log # Location of fonts used by older print filters... @@ -54,10 +55,10 @@ ErrorLog @CUPS_LOGDIR@/error_log # Location of LPD configuration #LPDConfigFile @CUPS_DEFAULT_LPD_CONFIG_FILE@ -# Location of the file logging all pages printed by the scheduler and any -# helper programs; may be the name "syslog". If not an absolute path, the value -# of ServerRoot is used as the root directory. Also see the "PageLogFormat" -# directive in cupsd.conf. +# Location of the file logging all pages printed by the scheduler and +# any helper programs; may be the name "syslog" or "journal". If not +# an absolute path, the value of ServerRoot is used as the root +# directory. Also see the "PageLogFormat" directive in cupsd.conf. PageLog @CUPS_LOGDIR@/page_log # Location of the file listing all of the local printers... diff -up cups-2.0rc1/config.h.in.journal cups-2.0rc1/config.h.in --- cups-2.0rc1/config.h.in.journal 2014-08-30 03:51:22.000000000 +0200 +++ cups-2.0rc1/config.h.in 2014-09-12 17:47:14.668190332 +0200 @@ -470,6 +470,13 @@ /* + * Do we have systemd-journal support? + */ + +#undef HAVE_JOURNAL + + +/* * Various scripting languages... */ diff -up cups-2.0rc1/config-scripts/cups-startup.m4.journal cups-2.0rc1/config-scripts/cups-startup.m4 --- cups-2.0rc1/config-scripts/cups-startup.m4.journal 2014-03-27 02:15:48.000000000 +0100 +++ cups-2.0rc1/config-scripts/cups-startup.m4 2014-09-12 17:48:58.435737311 +0200 @@ -15,8 +15,10 @@ dnl ONDEMANDFLAGS="" ONDEMANDLIBS="" +SDJLIBS="" AC_SUBST(ONDEMANDFLAGS) AC_SUBST(ONDEMANDLIBS) +AC_SUBST(SDJLIBS) dnl Launchd is used on OS X/Darwin... AC_ARG_ENABLE(launchd, [ --disable-launchd disable launchd support]) @@ -71,6 +73,15 @@ if test x$enable_systemd != xno; then fi fi +AC_MSG_CHECKING(for libsystemd-journal) +if $PKGCONFIG --exists libsystemd-journal; then + AC_MSG_RESULT(yes) + SDJLIBS=`$PKGCONFIG --libs libsystemd-journal` + AC_DEFINE(HAVE_JOURNAL) +else + AC_MSG_RESULT(no) +fi + dnl Solaris uses smf SMFMANIFESTDIR="" AC_SUBST(SMFMANIFESTDIR) diff -up cups-2.0rc1/doc/help/man-cups-files.conf.html.journal cups-2.0rc1/doc/help/man-cups-files.conf.html --- cups-2.0rc1/doc/help/man-cups-files.conf.html.journal 2014-06-13 02:01:23.000000000 +0200 +++ cups-2.0rc1/doc/help/man-cups-files.conf.html 2014-09-12 17:47:14.669190318 +0200 @@ -24,9 +24,11 @@ The following directives are understood
@@ -51,9 +53,12 @@ The default is usually "/usr/share/doc/c
CUPS_JOB_ID
filled in.
The server name may be included in filenames using the string "%s", for example:
@@ -96,8 +101,11 @@ The default group is operating system sp The default is "0644".
CUPS_JOB_ID
and CUPS_PAGE_NUMBER
will be filled in.
Specifying a blank filename disables page log generation.
The server name may be included in filenames using the string "%s", for example:
diff -up cups-2.0rc1/Makedefs.in.journal cups-2.0rc1/Makedefs.in --- cups-2.0rc1/Makedefs.in.journal 2014-09-12 17:47:14.617191046 +0200 +++ cups-2.0rc1/Makedefs.in 2014-09-12 17:47:14.669190318 +0200 @@ -148,6 +148,7 @@ LINKCUPSIMAGE = @LINKCUPSIMAGE@ LIBS = $(LINKCUPS) $(COMMONLIBS) ONDEMANDFLAGS = @ONDEMANDFLAGS@ ONDEMANDLIBS = @ONDEMANDLIBS@ +SDJLIBS = @SDJLIBS@ OPTIM = @OPTIM@ OPTIONS = PAMLIBS = @PAMLIBS@ diff -up cups-2.0rc1/man/cups-files.conf.man.in.journal cups-2.0rc1/man/cups-files.conf.man.in --- cups-2.0rc1/man/cups-files.conf.man.in.journal 2014-06-13 02:01:23.000000000 +0200 +++ cups-2.0rc1/man/cups-files.conf.man.in 2014-09-12 17:47:14.669190318 +0200 @@ -33,9 +33,12 @@ The following directives are understood \fBAccessLog \fIfilename\fR .TP 5 \fBAccessLog syslog\fR +.TP 5 +\fBAccessLog journal\fR Defines the access log filename. Specifying a blank filename disables access log generation. The value "syslog" causes log entries to be sent to the system log daemon. +The value "journal" causes access information to be sent to the system log instead of a plain file. The server name may be included in filenames using the string "%s", for example: .nf @@ -65,9 +68,13 @@ The default is usually "/usr/share/doc/c \fBErrorLog \fIfilename\fR .TP 5 \fBErrorLog syslog\fR +.TP 5 +\fBErrorLog journal\fR Defines the error log filename. Specifying a blank filename disables error log generation. The value "syslog" causes log entries to be sent to the system log daemon. +The value "journal" causes error information to be sent to the system journal instead of a plain file. +Information relating to a specific job is logged with the field \fICUPS_JOB_ID\fR filled in. The server name may be included in filenames using the string "%s", for example: .nf @@ -125,8 +132,12 @@ The default is "0644". \fBPageLog \fR[ \fIfilename\fR ] .TP 5 \fBPageLog syslog\fR +.TP 5 +\fBPageLog journal\fR Defines the page log filename. The value "syslog" causes log entries to be sent to the system log daemon. +The value "journal" causes the page information to be sent to the system journal instead of a plain file. +The fields \fICUPS_JOB_ID\fR and \fICUPS_PAGE_NUMBER\fR will be filled in. Specifying a blank filename disables page log generation. The server name may be included in filenames using the string "%s", for example: .nf diff -up cups-2.0rc1/scheduler/conf.c.journal cups-2.0rc1/scheduler/conf.c --- cups-2.0rc1/scheduler/conf.c.journal 2014-09-12 17:47:14.563191802 +0200 +++ cups-2.0rc1/scheduler/conf.c 2014-09-12 17:47:14.670190304 +0200 @@ -950,9 +950,9 @@ cupsdReadConfiguration(void) */ #ifdef HAVE_VSYSLOG - if (!strcmp(AccessLog, "syslog") || - !strcmp(ErrorLog, "syslog") || - !strcmp(PageLog, "syslog")) + if (!strcmp(AccessLog, "syslog") || !strcmp(AccessLog, "journal") || + !strcmp(ErrorLog, "syslog") || !strcmp(ErrorLog, "journal") || + !strcmp(PageLog, "syslog") || !strcmp(PageLog, "journal")) openlog("cupsd", LOG_PID | LOG_NOWAIT | LOG_NDELAY, LOG_LPR); #endif /* HAVE_VSYSLOG */ @@ -960,13 +960,13 @@ cupsdReadConfiguration(void) * Make sure each of the log files exists and gets rotated as necessary... */ - if (strcmp(AccessLog, "syslog")) + if (strcmp(AccessLog, "syslog") && strcmp(AccessLog, "journal")) cupsdCheckLogFile(&AccessFile, AccessLog); - if (strcmp(ErrorLog, "syslog")) + if (strcmp(ErrorLog, "syslog") && strcmp(ErrorLog, "journal")) cupsdCheckLogFile(&ErrorFile, ErrorLog); - if (strcmp(PageLog, "syslog")) + if (strcmp(PageLog, "syslog") && strcmp(PageLog, "journal")) cupsdCheckLogFile(&PageFile, PageLog); /* diff -up cups-2.0rc1/scheduler/conf.h.journal cups-2.0rc1/scheduler/conf.h --- cups-2.0rc1/scheduler/conf.h.journal 2014-09-12 17:47:14.563191802 +0200 +++ cups-2.0rc1/scheduler/conf.h 2014-09-12 17:47:14.671190290 +0200 @@ -298,6 +298,8 @@ extern int cupsdLogMessage(int level, co extern int cupsdLogPage(cupsd_job_t *job, const char *page); extern int cupsdLogRequest(cupsd_client_t *con, http_status_t code); extern int cupsdReadConfiguration(void); +extern int cupsdWriteErrorLogJob(cupsd_job_t *job, int level, + const char *message); extern int cupsdWriteErrorLog(int level, const char *message); diff -up cups-2.0rc1/scheduler/log.c.journal cups-2.0rc1/scheduler/log.c --- cups-2.0rc1/scheduler/log.c.journal 2014-09-12 17:47:14.599191298 +0200 +++ cups-2.0rc1/scheduler/log.c 2014-09-12 17:47:14.671190290 +0200 @@ -23,6 +23,9 @@ #include#include #include +#ifdef HAVE_JOURNAL +# include +#endif /* HAVE_JOURNAL */ /* @@ -603,8 +606,17 @@ cupsdLogJob(cupsd_job_t *job, /* I - Jo } else if (level <= LogLevel && (level != CUPSD_LOG_INFO || LogLevel >= CUPSD_LOG_DEBUG)) - return (cupsdWriteErrorLog(level, log_line)); - else + { + if (!strcmp (ErrorLog, "journal")) +#ifdef HAVE_JOURNAL + return (sd_journal_send ("MESSAGE=%s", log_line, + "PRIORITY=%d", syslevels[level], + "CUPS_JOB_ID=%d", job ? job->id : -1, + NULL)) ? 0 : 1; + else +#endif /* HAVE_JOURNAL */ + return (cupsdWriteErrorLog(level, log_line)); + } else return (1); } else @@ -860,6 +872,15 @@ cupsdLogPage(cupsd_job_t *job, /* I - J *bufptr = '\0'; +#ifdef HAVE_JOURNAL + if (!strcmp(PageLog, "journal")) + return (sd_journal_send ("MESSAGE=%s", buffer, + "PRIORITY=%d", LOG_INFO, + "CUPS_JOB_ID=%d", job->id, + "CUPS_PAGE_NUMBER=%s", number, + NULL) ? 0 : 1); +#endif /* HAVE_JOURNAL */ + #ifdef HAVE_VSYSLOG /* * See if we are logging pages via syslog... @@ -1037,7 +1058,7 @@ cupsdLogRequest(cupsd_client_t *con, /* * See if we are logging accesses via syslog... */ - if (!strcmp(AccessLog, "syslog")) + if (!strcmp(AccessLog, "syslog") || !strcmp(AccessLog, "journal")) { syslog(LOG_INFO, "REQUEST %s - %s \"%s %s HTTP/%d.%d\" %d " CUPS_LLFMT " %s %s\n", @@ -1091,8 +1112,9 @@ cupsdLogRequest(cupsd_client_t *con, /* */ int /* O - 1 on success, 0 on failure */ -cupsdWriteErrorLog(int level, /* I - Log level */ - const char *message) /* I - Message string */ +cupsdWriteErrorLogJob(cupsd_job_t *job, /* I - Job or NULL */ + int level, /* I - Log level */ + const char *message) /* I - Message string */ { int ret = 1; /* Return value */ static const char levels[] = /* Log levels... */ @@ -1110,12 +1132,25 @@ cupsdWriteErrorLog(int level, /* }; +#ifdef HAVE_JOURNAL + if (!strcmp(ErrorLog, "journal")) + { + if (job) + { + return (sd_journal_send ("MESSAGE=%s", message, + "PRIORITY=%d", syslevels[level], + "CUPS_JOB_ID=%d", job->id, + NULL) ? 0 : 1); + } else + return (sd_journal_print (syslevels[level], "%s", message) ? 0 : 1); + } +#endif /* HAVE_JOURNAL */ #ifdef HAVE_VSYSLOG /* * See if we are logging errors via syslog... */ - if (!strcmp(ErrorLog, "syslog")) + if (!strcmp(ErrorLog, "syslog") || !strcmp(ErrorLog, "journal")) { syslog(syslevels[level], "%s", message); return (1); @@ -1149,6 +1184,18 @@ cupsdWriteErrorLog(int level, /* } +/* + * 'cupsdWriteErrorLog()' - Write a line to the ErrorLog. + */ + +int /* O - 1 on success, 0 on failure */ +cupsdWriteErrorLog(int level, /* I - Log level */ + const char *message) /* I - Message string */ +{ + return (cupsdWriteErrorLogJob(NULL, level, message)); +} + + /* * 'format_log_line()' - Format a line for a log file. * diff -up cups-2.0rc1/scheduler/Makefile.journal cups-2.0rc1/scheduler/Makefile --- cups-2.0rc1/scheduler/Makefile.journal 2014-09-12 17:47:14.653190542 +0200 +++ cups-2.0rc1/scheduler/Makefile 2014-09-12 17:47:14.672190276 +0200 @@ -382,7 +382,7 @@ cupsd: $(CUPSDOBJS) $(LIBCUPSMIME) ../cu $(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) -L. -lcupsmime \ $(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \ $(LIBPAPER) $(LIBMALLOC) $(SERVERLIBS) $(ONDEMANDLIBS) \ - $(DNSSDLIBS) $(LIBS) $(LIBGSSAPI) $(LIBWRAP) + $(DNSSDLIBS) $(LIBS) $(LIBGSSAPI) $(LIBWRAP) $(SDJLIBS) cupsd-static: $(CUPSDOBJS) libcupsmime.a ../cups/$(LIBCUPSSTATIC) echo Linking $@... @@ -390,7 +390,7 @@ cupsd-static: $(CUPSDOBJS) libcupsmime.a $(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \ ../cups/$(LIBCUPSSTATIC) $(COMMONLIBS) $(LIBZ) $(LIBPAPER) \ $(LIBMALLOC) $(SERVERLIBS) $(ONDEMANDLIBS) $(DNSSDLIBS) \ - $(LIBGSSAPI) $(LIBWRAP) + $(LIBGSSAPI) $(LIBWRAP) $(SDJLIBS) #