Blob Blame History Raw
diff -up cups-1.7.0/Makedefs.in.journal cups-1.7.0/Makedefs.in
--- cups-1.7.0/Makedefs.in.journal	2013-10-24 16:35:59.103969053 +0100
+++ cups-1.7.0/Makedefs.in	2013-10-24 16:35:59.175969379 +0100
@@ -143,6 +143,7 @@ IPPFIND_BIN	=	@IPPFIND_BIN@
 IPPFIND_MAN	=	@IPPFIND_MAN@
 LAUNCHDLIBS	=	@LAUNCHDLIBS@
 SDLIBS		=	@SDLIBS@
+SDJLIBS		=	@SDJLIBS@
 LDFLAGS		=	-L../cgi-bin -L../cups -L../filter -L../ppdc \
 			-L../scheduler @LDARCHFLAGS@ \
 			@LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM)
diff -up cups-1.7.0/config-scripts/cups-systemd.m4.journal cups-1.7.0/config-scripts/cups-systemd.m4
--- cups-1.7.0/config-scripts/cups-systemd.m4.journal	2013-10-24 16:35:59.101969044 +0100
+++ cups-1.7.0/config-scripts/cups-systemd.m4	2013-10-24 16:35:59.175969379 +0100
@@ -22,6 +22,15 @@ if test "x$with_systemdsystemunitdir" !=
 	fi
 fi
 
+SDJLIBS=""
+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
 if test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ; then
         SYSTEMD_UNITS="cups.service cups.socket cups.path"
 else
@@ -30,6 +39,7 @@ fi
 
 AC_SUBST(SYSTEMD_UNITS)
 AC_SUBST(SDLIBS)
+AC_SUBST(SDJLIBS)
 
 dnl
 dnl "$Id$"
diff -up cups-1.7.0/config.h.in.journal cups-1.7.0/config.h.in
--- cups-1.7.0/config.h.in.journal	2013-10-24 16:35:59.101969044 +0100
+++ cups-1.7.0/config.h.in	2013-10-24 16:35:59.176969383 +0100
@@ -458,6 +458,13 @@
 
 
 /*
+ * Do we have systemd-journal support?
+ */
+
+#undef HAVE_JOURNAL
+
+
+/*
  * Various scripting languages...
  */
 
diff -up cups-1.7.0/scheduler/Makefile.journal cups-1.7.0/scheduler/Makefile
--- cups-1.7.0/scheduler/Makefile.journal	2013-10-24 16:35:59.133969189 +0100
+++ cups-1.7.0/scheduler/Makefile	2013-10-24 16:35:59.176969383 +0100
@@ -383,7 +383,7 @@ cupsd:	$(CUPSDOBJS) $(LIBCUPSMIME) ../cu
 	$(CC) $(LDFLAGS) -o cupsd $(CUPSDOBJS) -L. -lcupsmime \
 		$(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \
 		$(LIBPAPER) $(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBS) \
-		$(LIBGSSAPI) $(LIBWRAP) $(SDLIBS)
+		$(LIBGSSAPI) $(LIBWRAP) $(SDLIBS) $(SDJLIBS)
 
 cupsd-static:	$(CUPSDOBJS) libcupsmime.a ../cups/$(LIBCUPSSTATIC)
 	echo Linking $@...
@@ -391,7 +391,7 @@ cupsd-static:	$(CUPSDOBJS) libcupsmime.a
 		$(LIBZ) $(SSLLIBS) $(LIBSLP) $(LIBLDAP) $(PAMLIBS) \
 		../cups/$(LIBCUPSSTATIC) $(COMMONLIBS) $(LIBZ) $(LIBPAPER) \
 		$(LIBMALLOC) $(SERVERLIBS) $(DNSSDLIBS) $(LIBGSSAPI) \
-		$(LIBWRAP)  $(SDLIBS)
+		$(LIBWRAP)  $(SDLIBS) $(SDJLIBS)
 
 tls.o:	tls-darwin.c tls-gnutls.c tls-openssl.c
 
diff -up cups-1.7.0/scheduler/conf.c.journal cups-1.7.0/scheduler/conf.c
--- cups-1.7.0/scheduler/conf.c.journal	2013-10-24 16:35:59.058968850 +0100
+++ cups-1.7.0/scheduler/conf.c	2013-10-24 16:35:59.176969383 +0100
@@ -973,9 +973,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 */
 
@@ -983,13 +983,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-1.7.0/scheduler/conf.h.journal cups-1.7.0/scheduler/conf.h
--- cups-1.7.0/scheduler/conf.h.journal	2013-10-24 16:35:59.058968850 +0100
+++ cups-1.7.0/scheduler/conf.h	2013-10-24 16:35:59.177969388 +0100
@@ -297,6 +297,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-1.7.0/scheduler/log.c.journal cups-1.7.0/scheduler/log.c
--- cups-1.7.0/scheduler/log.c.journal	2013-10-24 16:35:59.083968963 +0100
+++ cups-1.7.0/scheduler/log.c	2013-10-24 16:38:02.352526508 +0100
@@ -21,6 +21,7 @@
  *   cupsdLogMessage()    - Log a message to the error log file.
  *   cupsdLogPage()       - Log a page to the page log file.
  *   cupsdLogRequest()    - Log an HTTP request in Common Log Format.
+ *   cupsdWriteErrorLogJob() - Write a job message to the ErrorLog.
  *   cupsdWriteErrorLog() - Write a line to the ErrorLog.
  *   format_log_line()    - Format a line for a log file.
  */
@@ -35,6 +36,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#ifdef HAVE_JOURNAL
+# include <systemd/sd-journal.h>
+#endif /* HAVE_JOURNAL */
 
 
 /*
@@ -558,8 +562,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
@@ -788,6 +801,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...
@@ -963,7 +985,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",
@@ -1017,8 +1039,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 */
 {
   static const char	levels[] =	/* Log levels... */
 		{
@@ -1035,12 +1058,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);
@@ -1066,6 +1102,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.
  *