8955d8c
diff -up cups-2.0.0/conf/cups-files.conf.in.journal cups-2.0.0/conf/cups-files.conf.in
8955d8c
--- cups-2.0.0/conf/cups-files.conf.in.journal	2014-03-03 16:46:23.000000000 +0000
8955d8c
+++ cups-2.0.0/conf/cups-files.conf.in	2014-11-06 14:10:21.874448772 +0000
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...
8955d8c
@@ -42,11 +43,11 @@ 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.
670e473
-ErrorLog @CUPS_LOGDIR@/error_log
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.
670e473
+ErrorLog journal
6dd0746
 
6dd0746
 # Location of fonts used by older print filters...
670e473
 #FontPath @CUPS_FONTPATH@
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...
8955d8c
diff -up cups-2.0.0/config-scripts/cups-startup.m4.journal cups-2.0.0/config-scripts/cups-startup.m4
8955d8c
--- cups-2.0.0/config-scripts/cups-startup.m4.journal	2014-03-27 01:15:48.000000000 +0000
8955d8c
+++ cups-2.0.0/config-scripts/cups-startup.m4	2014-11-06 14:10:00.186328322 +0000
8955d8c
@@ -56,11 +56,11 @@ if test x$enable_systemd != xno; then
8955d8c
 	        	AC_MSG_ERROR(Need pkg-config to enable systemd support.)
8955d8c
                 fi
8955d8c
         else
8955d8c
-        	AC_MSG_CHECKING(for libsystemd-daemon)
8955d8c
-                if $PKGCONFIG --exists libsystemd-daemon; then
8955d8c
+		AC_MSG_CHECKING(for libsystemd)
8955d8c
+                if $PKGCONFIG --exists libsystemd; then
8955d8c
                         AC_MSG_RESULT(yes)
8955d8c
-                        ONDEMANDFLAGS=`$PKGCONFIG --cflags libsystemd-daemon`
8955d8c
-                        ONDEMANDLIBS=`$PKGCONFIG --libs libsystemd-daemon`
8955d8c
+                        ONDEMANDFLAGS=`$PKGCONFIG --cflags libsystemd`
8955d8c
+                        ONDEMANDLIBS=`$PKGCONFIG --libs libsystemd`
8955d8c
                         AC_DEFINE(HAVE_SYSTEMD)
8955d8c
 			if test "x$SYSTEMD_DIR" = x; then
8955d8c
 			        SYSTEMD_DIR="`$PKGCONFIG --variable=systemdsystemunitdir systemd`"
8955d8c
diff -up cups-2.0.0/doc/help/man-cups-files.conf.html.journal cups-2.0.0/doc/help/man-cups-files.conf.html
8955d8c
--- cups-2.0.0/doc/help/man-cups-files.conf.html.journal	2014-06-13 01:01:23.000000000 +0100
8955d8c
+++ cups-2.0.0/doc/help/man-cups-files.conf.html	2014-11-06 14:10:00.187328328 +0000
8955d8c
@@ -24,6 +24,7 @@ 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.
8955d8c
@@ -51,6 +52,7 @@ 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.
8955d8c
@@ -96,6 +98,7 @@ 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
 Specifying a blank filename disables page log generation.
8955d8c
diff -up cups-2.0.0/man/cups-files.conf.man.in.journal cups-2.0.0/man/cups-files.conf.man.in
8955d8c
--- cups-2.0.0/man/cups-files.conf.man.in.journal	2014-06-13 01:01:23.000000000 +0100
8955d8c
+++ cups-2.0.0/man/cups-files.conf.man.in	2014-11-06 14:10:00.187328328 +0000
8955d8c
@@ -33,9 +33,13 @@ 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.
8955d8c
-The value "syslog" causes log entries to be sent to the system log daemon.
8955d8c
+The value "syslog" causes log entries to be sent to the system log
8955d8c
+daemon. The value "journal" causes log entries to be sent to the
8955d8c
+systemd journal.
6dd0746
 The server name may be included in filenames using the string "%s", for example:
6dd0746
 .nf
6dd0746
 
8955d8c
@@ -65,9 +69,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.
8955d8c
-The value "syslog" causes log entries to be sent to the system log daemon.
8955d8c
+The value "syslog" causes log entries to be sent to the system log
8955d8c
+daemon. The value "journal" causes log entries to be sent to the
8955d8c
+systemd journal.
6dd0746
 The server name may be included in filenames using the string "%s", for example:
6dd0746
 .nf
6dd0746
 
8955d8c
@@ -125,8 +133,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.
8955d8c
-The value "syslog" causes log entries to be sent to the system log daemon.
8955d8c
+The value "syslog" causes log entries to be sent to the system log
8955d8c
+daemon. The value "journal" causes log entries to be sent to the
8955d8c
+systemd journal.
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
8955d8c
diff -up cups-2.0.0/scheduler/conf.c.journal cups-2.0.0/scheduler/conf.c
8955d8c
--- cups-2.0.0/scheduler/conf.c.journal	2014-11-06 14:10:00.132328022 +0000
8955d8c
+++ cups-2.0.0/scheduler/conf.c	2014-11-06 14:10:00.187328328 +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
  /*
8955d8c
diff -up cups-2.0.0/scheduler/conf.h.journal cups-2.0.0/scheduler/conf.h
8955d8c
--- cups-2.0.0/scheduler/conf.h.journal	2014-11-06 14:10:00.132328022 +0000
8955d8c
+++ cups-2.0.0/scheduler/conf.h	2014-11-06 14:10:00.188328333 +0000
8955d8c
@@ -291,16 +291,69 @@ extern int	cupsdLogGSSMessage(int level,
8955d8c
 		                   OM_uint32 minor_status,
670e473
 		                   const char *message, ...);
670e473
 #endif /* HAVE_GSSAPI */
670e473
-extern int	cupsdLogJob(cupsd_job_t *job, int level, const char *message,
670e473
-		            ...) __attribute__((__format__(__printf__, 3, 4)));
670e473
-extern int	cupsdLogMessage(int level, const char *message, ...)
670e473
-		__attribute__ ((__format__ (__printf__, 2, 3)));
670e473
+extern int	_cupsdLogJobWithLocation(const char *file,
670e473
+					 const char *line,
670e473
+					 const char *func,
670e473
+					 cupsd_job_t *job,
670e473
+					 int level,
670e473
+					 const char *message,
670e473
+					 ...)
670e473
+		__attribute__((__format__(__printf__, 6, 7)));
670e473
+extern int	_cupsdLogMessageWithLocation(const char *file,
670e473
+					     const char *line,
670e473
+					     const char *func,
670e473
+					     int level,
670e473
+					     const char *message,
670e473
+					     ...)
670e473
+		__attribute__ ((__format__ (__printf__, 5, 6)));
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);
670e473
-extern int	cupsdWriteErrorLog(int level, const char *message);
670e473
+extern int	_cupsdWriteErrorLogJobWithLocation(const char *file,
670e473
+						   const char *line,
670e473
+						   const char *func,
670e473
+						   cupsd_job_t *job,
670e473
+						   int level,
670e473
+						   const char *message);
670e473
+extern int	_cupsdWriteErrorLogWithLocation(const char *file,
670e473
+						const char *line,
670e473
+						const char *func,
670e473
+						int level, const char *message);
670e473
 
670e473
 
670e473
+#ifndef _CUPSD_STRINGIFY
670e473
+#define _CUPSD_XSTRINGIFY(x) #x
670e473
+#define _CUPSD_STRINGIFY(x) _CUPSD_XSTRINGIFY(x)
670e473
+#endif /* !defined(_CUPSD_STRINGIFY) */
670e473
+
670e473
+#define cupsdLogJob(...)						\
670e473
+	_cupsdLogJobWithLocation("CODE_FILE=" __FILE__,			\
670e473
+				 "CODE_LINE="				\
670e473
+				 _CUPSD_STRINGIFY(__LINE__),		\
670e473
+				 __func__,				\
670e473
+				 __VA_ARGS__)
670e473
+
670e473
+#define cupsdLogMessage(...)						\
670e473
+	_cupsdLogMessageWithLocation("CODE_FILE=" __FILE__,		\
670e473
+				     "CODE_LINE="			\
670e473
+				     _CUPSD_STRINGIFY(__LINE__),	\
670e473
+				     __func__,				\
670e473
+				     __VA_ARGS__)
670e473
+
670e473
+#define cupsdWriteErrorLogJob(...)					\
670e473
+	_cupsdWriteErrorLogJobWithLocation("CODE_FILE=" __FILE__,	\
670e473
+			       "CODE_LINE="				\
670e473
+			       _CUPSD_STRINGIFY(__LINE__),		\
670e473
+			       __func__,				\
670e473
+			       __VA_ARGS__)
670e473
+
670e473
+#define cupsdWriteErrorLog(...)					\
670e473
+	_cupsdWriteErrorLogWithLocation("CODE_FILE=" __FILE__,	\
670e473
+			    "CODE_LINE="			\
670e473
+			    _CUPSD_STRINGIFY(__LINE__),		\
670e473
+			    __func__,				\
670e473
+			    __VA_ARGS__)
670e473
+
670e473
 /*
8955d8c
  * End of "$Id: conf.h 11789 2014-04-02 16:52:53Z msweet $".
670e473
  */
8955d8c
diff -up cups-2.0.0/scheduler/log.c.journal cups-2.0.0/scheduler/log.c
8955d8c
--- cups-2.0.0/scheduler/log.c.journal	2014-11-06 14:10:00.154328144 +0000
8955d8c
+++ cups-2.0.0/scheduler/log.c	2014-11-06 14:10:00.188328333 +0000
8955d8c
@@ -23,6 +23,12 @@
4fb45e1
 #include <sys/types.h>
4fb45e1
 #include <sys/stat.h>
4fb45e1
 #include <unistd.h>
8955d8c
+#include <sys/uio.h>
670e473
+#ifdef HAVE_SYSTEMD
670e473
+/* We handle location fields ourselves */
670e473
+# define SD_JOURNAL_SUPPRESS_LOCATION
4fb45e1
+# include <systemd/sd-journal.h>
670e473
+#endif /* HAVE_SYSTEMD */
4fb45e1
 
4fb45e1
 
4fb45e1
 /*
8955d8c
@@ -509,15 +515,135 @@ cupsdLogClient(cupsd_client_t *con,	/* I
8955d8c
 }
670e473
 
670e473
 
670e473
+#ifdef HAVE_SYSTEMD
670e473
+static int
670e473
+dup_iovec_string(struct iovec *vec,
670e473
+		 const char *str)
670e473
+{
670e473
+  vec->iov_base = strdup (str);
670e473
+  vec->iov_len = strlen (str);
670e473
+  return (vec->iov_base ? 1 : 0);
670e473
+}
670e473
+
670e473
+
670e473
+/*
670e473
+ * '_cupsdLogToJournal()' - Log to journal with fields
670e473
+ */
670e473
+static int				/* O - 1 on success, 0 on error */
670e473
+_cupsdLogToJournal(const char	*file,	/* I - Code file */
670e473
+		   const char	*line,	/* I - Code line */
670e473
+		   const char	*func,	/* I - Code func */
670e473
+		   cupsd_job_t	*job,	/* I - Job or NULL */
670e473
+		   int		level,	/* I - Log level */
670e473
+		   const char	*message)/* I - Formatted message */
670e473
+{
670e473
+  size_t		n_journal_fields;
670e473
+  struct iovec		*journal_fields = NULL;
670e473
+  char			buffer[256];
670e473
+  int			result = 1;
670e473
+
670e473
+ /*
670e473
+  * There will be at least 5 fields:
670e473
+  * CODE_FILE, CODE_LINE, CODE_FUNC, MESSAGE, PRIORITY
670e473
+  */
670e473
+
670e473
+  n_journal_fields = 5;
670e473
+
670e473
+  if (job)
670e473
+  {
670e473
+    n_journal_fields++; /* CUPS_JOB_ID */
670e473
+
670e473
+    if (job->dest)
670e473
+      n_journal_fields++; /* CUPS_DEST */
670e473
+
670e473
+    if (job->printer)
670e473
+      n_journal_fields++; /* CUPS_PRINTER */
670e473
+  }
670e473
+
670e473
+  journal_fields = calloc (n_journal_fields, sizeof (struct iovec));
670e473
+  if (!journal_fields)
670e473
+    return (0);
670e473
+
670e473
+  n_journal_fields = 0;
670e473
+
670e473
+  result = dup_iovec_string (&journal_fields[n_journal_fields], file);
670e473
+
670e473
+  if (result)
670e473
+  {
670e473
+    n_journal_fields++;
670e473
+    result = dup_iovec_string (&journal_fields[n_journal_fields], line);
670e473
+  }
670e473
+
670e473
+  if (result)
670e473
+  {
670e473
+    n_journal_fields++;
670e473
+    snprintf (buffer, sizeof (buffer), "CODE_FUNC=%s", func);
670e473
+    result = dup_iovec_string (&journal_fields[n_journal_fields], buffer);
670e473
+  }
670e473
+
670e473
+  if (result)
670e473
+  {
670e473
+    n_journal_fields++;
670e473
+    snprintf (buffer, sizeof (buffer), "MESSAGE=%s", log_line);
670e473
+    result = dup_iovec_string (&journal_fields[n_journal_fields], buffer);
670e473
+  }
670e473
+
670e473
+  if (result)
670e473
+  {
670e473
+    n_journal_fields++;
670e473
+    snprintf (buffer, sizeof (buffer), "PRIORITY=%i", syslevels[level]);
670e473
+    result = dup_iovec_string (&journal_fields[n_journal_fields], buffer);
670e473
+  }
670e473
+
670e473
+  if (result && job)
670e473
+  {
670e473
+    n_journal_fields++;
670e473
+    snprintf (buffer, sizeof (buffer), "CUPS_JOB_ID=%d", job->id);
670e473
+    result = dup_iovec_string (&journal_fields[n_journal_fields], buffer);
670e473
+
670e473
+    if (result && job->dest)
670e473
+    {
670e473
+      n_journal_fields++;
670e473
+      snprintf (buffer, sizeof (buffer), "CUPS_DEST=%s", job->dest);
670e473
+      result = dup_iovec_string (&journal_fields[n_journal_fields], buffer);
670e473
+    }
670e473
+
670e473
+    if (result && job->printer)
670e473
+    {
670e473
+      n_journal_fields++;
670e473
+      snprintf (buffer, sizeof (buffer), "CUPS_PRINTER=%s",
670e473
+		job->printer->name);
670e473
+      result = dup_iovec_string (&journal_fields[n_journal_fields], buffer);
670e473
+    }
670e473
+  }
670e473
+
670e473
+  if (result)
670e473
+  {
670e473
+    n_journal_fields++;
670e473
+    result = sd_journal_sendv (journal_fields, n_journal_fields);
670e473
+  }
670e473
+
670e473
+  while (n_journal_fields > 0)
670e473
+    free (journal_fields[--n_journal_fields].iov_base);
670e473
+
670e473
+  free (journal_fields);
670e473
+  return (result);
670e473
+}
670e473
+#endif /* HAVE_SYSTEMD */
670e473
+
670e473
+
670e473
 /*
670e473
  * 'cupsdLogJob()' - Log a job message.
670e473
  */
670e473
 
670e473
-int					/* O - 1 on success, 0 on error */
670e473
-cupsdLogJob(cupsd_job_t *job,		/* I - Job */
670e473
-            int         level,		/* I - Log level */
670e473
-	    const char  *message,	/* I - Printf-style message string */
670e473
-	    ...)			/* I - Additional arguments as needed */
670e473
+int						/* O - 1 on success, 0 on error */
670e473
+_cupsdLogJobWithLocation(const char *file,	/* I - Code file */
670e473
+			 const char *line,	/* I - Code line */
670e473
+			 const char *func,	/* I - Code func */
670e473
+			 cupsd_job_t *job,	/* I - Job */
670e473
+			 int         level,	/* I - Log level */
670e473
+			 const char  *message,	/* I - Printf-style message string */
670e473
+			 ...)			/* I - Additional arguments as needed */
670e473
 {
670e473
   va_list		ap, ap2;	/* Argument pointers */
670e473
   char			jobmsg[1024];	/* Format string for job message */
8955d8c
@@ -603,8 +729,14 @@ 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
+    {
670e473
+#ifdef HAVE_SYSTEMD
4fb45e1
+      if (!strcmp (ErrorLog, "journal"))
670e473
+	return (_cupsdLogToJournal (file, line, func, job, level, log_line));
4fb45e1
+      else
670e473
+#endif /* HAVE_SYSTEMD */
4fb45e1
+	return (cupsdWriteErrorLog(level, log_line));
4fb45e1
+    } else
4fb45e1
       return (1);
4fb45e1
   }
4fb45e1
   else
8955d8c
@@ -617,10 +749,13 @@ cupsdLogJob(cupsd_job_t *job,		/* I - Jo
670e473
  * 'cupsdLogMessage()' - Log a message to the error log file.
670e473
  */
670e473
 
670e473
-int					/* O - 1 on success, 0 on error */
670e473
-cupsdLogMessage(int        level,	/* I - Log level */
670e473
-                const char *message,	/* I - printf-style message string */
670e473
-	        ...)			/* I - Additional args as needed */
670e473
+int						/* O - 1 on success, 0 on error */
670e473
+_cupsdLogMessageWithLocation(const char *file,	/* I - Code file */
670e473
+			     const char *line,	/* I - Code line */
670e473
+			     const char *func,	/* I - Code func */
670e473
+			     int        level,	/* I - Log level */
670e473
+			     const char *message, /* I - printf-style message string */
670e473
+			     ...)		/* I - Additional args as needed */
670e473
 {
670e473
   va_list		ap, ap2;	/* Argument pointers */
670e473
   int			status;		/* Formatting status */
8955d8c
@@ -664,10 +799,10 @@ cupsdLogMessage(int        level,	/* I -
670e473
   va_end(ap);
670e473
 
670e473
   if (status > 0)
670e473
-    return (cupsdWriteErrorLog(level, log_line));
670e473
+    return (_cupsdWriteErrorLogWithLocation(file, line, func, level, log_line));
670e473
   else
670e473
-    return (cupsdWriteErrorLog(CUPSD_LOG_ERROR,
670e473
-                               "Unable to allocate memory for log line!"));
670e473
+    return (_cupsdWriteErrorLogWithLocation(file, line, func, CUPSD_LOG_ERROR,
670e473
+					    "Unable to allocate memory for log line!"));
670e473
 }
670e473
 
670e473
 
8955d8c
@@ -860,6 +995,17 @@ cupsdLogPage(cupsd_job_t *job,		/* I - J
4fb45e1
 
4fb45e1
   *bufptr = '\0';
4fb45e1
 
670e473
+#ifdef HAVE_SYSTEMD
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,
670e473
+			     "CUPS_DEST=%s", job->dest,
670e473
+			     "CUPS_PRINTER=%s", job->printer->name,
4c07778
+			     "CUPS_PAGE_NUMBER=%s", number,
4fb45e1
+			     NULL) ? 0 : 1);
670e473
+#endif /* HAVE_SYSTEMD */
4fb45e1
+
4fb45e1
 #ifdef HAVE_VSYSLOG
4fb45e1
  /*
4fb45e1
   * See if we are logging pages via syslog...
8955d8c
@@ -1037,7 +1183,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",
8955d8c
@@ -1091,8 +1237,12 @@ 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 */
670e473
+_cupsdWriteErrorLogJobWithLocation(const char *file,	/* I - Code file */
670e473
+				   const char *line,	/* I - Code line */
670e473
+				   const char *func,	/* I - Code func */
670e473
+				   cupsd_job_t *job,	/* I - Job or NULL */
670e473
+				   int         level,	/* I - Log level */
670e473
+				   const char *message) /* I - Message string */
4fb45e1
 {
6dd0746
   int		ret = 1;		/* Return value */
4fb45e1
   static const char	levels[] =	/* Log levels... */
8955d8c
@@ -1110,6 +1260,10 @@ cupsdWriteErrorLog(int        level,	/*
4fb45e1
 		};
4fb45e1
 
4fb45e1
 
670e473
+#ifdef HAVE_SYSTEMD
4fb45e1
+  if (!strcmp(ErrorLog, "journal"))
670e473
+    return (_cupsdLogToJournal (file, line, func, job, level, message));
670e473
+#endif /* HAVE_SYSTEMD */
4fb45e1
 #ifdef HAVE_VSYSLOG
4fb45e1
  /*
4fb45e1
   * See if we are logging errors via syslog...
8955d8c
@@ -1149,6 +1303,22 @@ 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 */
670e473
+_cupsdWriteErrorLogWithLocation(const char *file,	/* I - Code file */
670e473
+				const char *line,	/* I - Code line */
670e473
+				const char *func,	/* I - Code func */
670e473
+				int          level,	/* I - Log level */
670e473
+				const char  *message)	/* I - Message string */
4fb45e1
+{
670e473
+  return (_cupsdWriteErrorLogJobWithLocation(file, line, func,
670e473
+					     NULL, level, message));
4fb45e1
+}
4fb45e1
+
4fb45e1
+
4fb45e1
 /*
4fb45e1
  * 'format_log_line()' - Format a line for a log file.
4fb45e1
  *