7cb9904
diff -up cups-1.7.1/config.h.in.journal cups-1.7.1/config.h.in
7cb9904
--- cups-1.7.1/config.h.in.journal	2014-02-17 16:48:19.089795987 +0000
7cb9904
+++ cups-1.7.1/config.h.in	2014-02-17 16:48:19.136796218 +0000
7cb9904
@@ -458,6 +458,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
 
7cb9904
diff -up cups-1.7.1/config-scripts/cups-systemd.m4.journal cups-1.7.1/config-scripts/cups-systemd.m4
7cb9904
--- cups-1.7.1/config-scripts/cups-systemd.m4.journal	2014-02-17 16:48:19.089795987 +0000
7cb9904
+++ cups-1.7.1/config-scripts/cups-systemd.m4	2014-02-17 16:48:19.136796218 +0000
4fb45e1
@@ -22,6 +22,15 @@ if test "x$with_systemdsystemunitdir" !=
4fb45e1
 	fi
4fb45e1
 fi
4fb45e1
 
4fb45e1
+SDJLIBS=""
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
4fb45e1
 if test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ; then
4fb45e1
         SYSTEMD_UNITS="cups.service cups.socket cups.path"
4fb45e1
 else
4fb45e1
@@ -30,6 +39,7 @@ fi
4fb45e1
 
4fb45e1
 AC_SUBST(SYSTEMD_UNITS)
4fb45e1
 AC_SUBST(SDLIBS)
4fb45e1
+AC_SUBST(SDJLIBS)
4fb45e1
 
4fb45e1
 dnl
4fb45e1
 dnl "$Id$"
7cb9904
diff -up cups-1.7.1/doc/help/ref-cups-files-conf.html.in.journal cups-1.7.1/doc/help/ref-cups-files-conf.html.in
7cb9904
--- cups-1.7.1/doc/help/ref-cups-files-conf.html.in.journal	2014-02-17 17:06:11.652078495 +0000
7cb9904
+++ cups-1.7.1/doc/help/ref-cups-files-conf.html.in	2014-02-17 17:11:50.675752398 +0000
7cb9904
@@ -18,6 +18,7 @@
7cb9904
 AccessLog /var/log/cups/access_log
7cb9904
 AccessLog /var/log/cups/access_log-%s
7cb9904
 AccessLog syslog
7cb9904
+AccessLog journal
7cb9904
 
4fb45e1
 
7cb9904
 

Description

7cb9904
@@ -36,6 +37,9 @@ server activity.

7cb9904
 

The special name "syslog" can be used to send the access

7cb9904
 information to the system log instead of a plain file.

4fb45e1
 
7cb9904
+

The special name "journal" can be used to send the access

7cb9904
+information to the system log instead of a plain file.

4fb45e1
+
7cb9904
 

The default access log file is

7cb9904
 /var/log/access_log.

7cb9904
 
7cb9904
@@ -108,6 +112,7 @@ language needed.

7cb9904
 ErrorLog /var/log/cups/error_log
7cb9904
 ErrorLog /var/log/cups/error_log-%s
7cb9904
 ErrorLog syslog
7cb9904
+ErrorLog journal
7cb9904
 
7cb9904
 
7cb9904
 

Description

7cb9904
@@ -124,6 +129,11 @@ default error log file is /var/log/
7cb9904
 

The special name "syslog" can be used to send the error

7cb9904
 information to the system log instead of a plain file.

7cb9904
 
7cb9904
+

The special name "journal" can be used to send the error

7cb9904
+information to the system journal instead of a plain file. Information
7cb9904
+relating to a specific job is logged with the field
7cb9904
+CUPS_JOB_ID filled in.

4fb45e1
+
4fb45e1
 
7cb9904
 

CUPS 1.4/OS X 10.6FatalErrors

4fb45e1
 
7cb9904
@@ -266,6 +276,7 @@ is 644.

7cb9904
 PageLog /var/log/cups/page_log
7cb9904
 PageLog /var/log/cups/page_log-%s
7cb9904
 PageLog syslog
7cb9904
+PageLog journal
7cb9904
 
4fb45e1
 
7cb9904
 

Description

7cb9904
@@ -282,6 +293,11 @@ default page log file is /var/log/c
7cb9904
 

The special name "syslog" can be used to send the page

7cb9904
 information to the system log instead of a plain file.

4fb45e1
 
7cb9904
+

The special name "journal" can be used to send the page information

7cb9904
+to the system journal instead of a plain file.  The fields
7cb9904
+CUPS_JOB_ID and CUPS_PAGE_NUMBER will be
7cb9904
+filled in.

7cb9904
+
7cb9904
 
7cb9904
 

Printcap

7cb9904
 
7cb9904
diff -up cups-1.7.1/Makedefs.in.journal cups-1.7.1/Makedefs.in
7cb9904
--- cups-1.7.1/Makedefs.in.journal	2014-02-17 16:48:19.090795992 +0000
7cb9904
+++ cups-1.7.1/Makedefs.in	2014-02-17 16:48:19.136796218 +0000
7cb9904
@@ -143,6 +143,7 @@ IPPFIND_BIN	=	@IPPFIND_BIN@
7cb9904
 IPPFIND_MAN	=	@IPPFIND_MAN@
7cb9904
 LAUNCHDLIBS	=	@LAUNCHDLIBS@
7cb9904
 SDLIBS		=	@SDLIBS@
7cb9904
+SDJLIBS		=	@SDJLIBS@
7cb9904
 LDFLAGS		=	-L../cgi-bin -L../cups -L../filter -L../ppdc \
7cb9904
 			-L../scheduler @LDARCHFLAGS@ \
7cb9904
 			@LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM)
7cb9904
diff -up cups-1.7.1/man/cups-files.conf.man.in.journal cups-1.7.1/man/cups-files.conf.man.in
7cb9904
--- cups-1.7.1/man/cups-files.conf.man.in.journal	2014-02-17 17:05:08.103764935 +0000
7cb9904
+++ cups-1.7.1/man/cups-files.conf.man.in	2014-02-17 17:06:48.131258521 +0000
7cb9904
@@ -29,6 +29,8 @@ on-line help for detailed descriptions:
7cb9904
 AccessLog filename
7cb9904
 .TP 5
7cb9904
 AccessLog syslog
7cb9904
+.TP 5
7cb9904
+AccessLog journal
7cb9904
 .br
7cb9904
 Defines the access log filename.
7cb9904
 .TP 5
7cb9904
@@ -48,6 +50,8 @@ Specifies the root directory for the int
7cb9904
 ErrorLog filename
7cb9904
 .TP 5
7cb9904
 ErrorLog syslog
7cb9904
+.TP 5
7cb9904
+ErrorLog journal
7cb9904
 .br
7cb9904
 Specifies the error log filename.
7cb9904
 .TP 5
7cb9904
@@ -83,6 +87,8 @@ Specifies the permissions for all log fi
7cb9904
 PageLog filename
7cb9904
 .TP 5
7cb9904
 PageLog syslog
7cb9904
+.TP 5
7cb9904
+PageLog journal
7cb9904
 .br
7cb9904
 Specifies the page log filename.
7cb9904
 .TP 5
7cb9904
diff -up cups-1.7.1/scheduler/conf.c.journal cups-1.7.1/scheduler/conf.c
7cb9904
--- cups-1.7.1/scheduler/conf.c.journal	2014-02-17 16:48:19.047795781 +0000
7cb9904
+++ cups-1.7.1/scheduler/conf.c	2014-02-17 16:48:19.137796223 +0000
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
  /*
7cb9904
diff -up cups-1.7.1/scheduler/conf.h.journal cups-1.7.1/scheduler/conf.h
7cb9904
--- cups-1.7.1/scheduler/conf.h.journal	2014-02-17 16:48:19.048795786 +0000
7cb9904
+++ cups-1.7.1/scheduler/conf.h	2014-02-17 16:48:19.138796228 +0000
4fb45e1
@@ -297,6 +297,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
 
7cb9904
diff -up cups-1.7.1/scheduler/log.c.journal cups-1.7.1/scheduler/log.c
7cb9904
--- cups-1.7.1/scheduler/log.c.journal	2014-02-17 16:48:19.073795909 +0000
7cb9904
+++ cups-1.7.1/scheduler/log.c	2014-02-17 16:48:19.138796228 +0000
4fb45e1
@@ -21,6 +21,7 @@
4fb45e1
  *   cupsdLogMessage()    - Log a message to the error log file.
4fb45e1
  *   cupsdLogPage()       - Log a page to the page log file.
4fb45e1
  *   cupsdLogRequest()    - Log an HTTP request in Common Log Format.
4fb45e1
+ *   cupsdWriteErrorLogJob() - Write a job message to the ErrorLog.
4fb45e1
  *   cupsdWriteErrorLog() - Write a line to the ErrorLog.
4fb45e1
  *   format_log_line()    - Format a line for a log file.
4fb45e1
  */
4fb45e1
@@ -35,6 +36,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
 /*
7cb9904
@@ -559,8 +563,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
7cb9904
@@ -789,6 +802,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...
7cb9904
@@ -964,7 +986,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",
7cb9904
@@ -1018,8 +1040,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
 {
4fb45e1
   static const char	levels[] =	/* Log levels... */
4fb45e1
 		{
7cb9904
@@ -1036,12 +1059,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);
7cb9904
@@ -1067,6 +1103,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
  *
7cb9904
diff -up cups-1.7.1/scheduler/Makefile.journal cups-1.7.1/scheduler/Makefile
7cb9904
--- cups-1.7.1/scheduler/Makefile.journal	2014-02-17 16:48:19.124796159 +0000
7cb9904
+++ cups-1.7.1/scheduler/Makefile	2014-02-17 16:48:19.137796223 +0000
7cb9904
@@ -383,7 +383,7 @@ cupsd:	$(CUPSDOBJS) $(LIBCUPSMIME) ../cu
7cb9904
 	$(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) -L. -lcupsmime \
7cb9904
 		$(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \
7cb9904
 		$(LIBPAPER) $(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBS) \
7cb9904
-		$(LIBGSSAPI) $(LIBWRAP) $(SDLIBS)
7cb9904
+		$(LIBGSSAPI) $(LIBWRAP) $(SDLIBS) $(SDJLIBS)
7cb9904
 
7cb9904
 cupsd-static:	$(CUPSDOBJS) libcupsmime.a ../cups/$(LIBCUPSSTATIC)
7cb9904
 	echo Linking $@...
7cb9904
@@ -391,7 +391,7 @@ cupsd-static:	$(CUPSDOBJS) libcupsmime.a
7cb9904
 		$(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \
7cb9904
 		../cups/$(LIBCUPSSTATIC) $(COMMONLIBS) $(LIBZ) $(LIBPAPER) \
7cb9904
 		$(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBGSSAPI) \
7cb9904
-		$(LIBWRAP)  $(SDLIBS)
7cb9904
+		$(LIBWRAP)  $(SDLIBS) $(SDJLIBS)
7cb9904
 
7cb9904
 tls.o:	tls-darwin.c tls-gnutls.c tls-openssl.c
7cb9904