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