Small journal support fixes for page logging and replayed job logs.

This commit is contained in:
Tim Waugh 2013-10-24 13:35:36 +01:00
parent 4fb45e11e6
commit 4c07778a26

View File

@ -1,6 +1,6 @@
diff -up cups-1.7rc1/Makedefs.in.journal cups-1.7rc1/Makedefs.in
--- cups-1.7rc1/Makedefs.in.journal 2013-10-21 16:18:06.323038476 +0100
+++ cups-1.7rc1/Makedefs.in 2013-10-21 16:18:06.373038711 +0100
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@
@ -9,9 +9,9 @@ diff -up cups-1.7rc1/Makedefs.in.journal cups-1.7rc1/Makedefs.in
LDFLAGS = -L../cgi-bin -L../cups -L../filter -L../ppdc \
-L../scheduler @LDARCHFLAGS@ \
@LDFLAGS@ @RELROFLAGS@ @PIEFLAGS@ $(OPTIM)
diff -up cups-1.7rc1/config-scripts/cups-systemd.m4.journal cups-1.7rc1/config-scripts/cups-systemd.m4
--- cups-1.7rc1/config-scripts/cups-systemd.m4.journal 2013-10-21 16:18:06.311038420 +0100
+++ cups-1.7rc1/config-scripts/cups-systemd.m4 2013-10-21 16:18:06.373038711 +0100
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
@ -36,9 +36,9 @@ diff -up cups-1.7rc1/config-scripts/cups-systemd.m4.journal cups-1.7rc1/config-s
dnl
dnl "$Id$"
diff -up cups-1.7rc1/config.h.in.journal cups-1.7rc1/config.h.in
--- cups-1.7rc1/config.h.in.journal 2013-10-21 16:18:06.311038420 +0100
+++ cups-1.7rc1/config.h.in 2013-10-21 16:18:06.373038711 +0100
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 @@
@ -53,9 +53,9 @@ diff -up cups-1.7rc1/config.h.in.journal cups-1.7rc1/config.h.in
* Various scripting languages...
*/
diff -up cups-1.7rc1/scheduler/Makefile.journal cups-1.7rc1/scheduler/Makefile
--- cups-1.7rc1/scheduler/Makefile.journal 2013-10-21 16:18:06.354038622 +0100
+++ cups-1.7rc1/scheduler/Makefile 2013-10-21 16:18:06.373038711 +0100
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) \
@ -74,9 +74,9 @@ diff -up cups-1.7rc1/scheduler/Makefile.journal cups-1.7rc1/scheduler/Makefile
tls.o: tls-darwin.c tls-gnutls.c tls-openssl.c
diff -up cups-1.7rc1/scheduler/conf.c.journal cups-1.7rc1/scheduler/conf.c
--- cups-1.7rc1/scheduler/conf.c.journal 2013-10-21 16:31:27.980798750 +0100
+++ cups-1.7rc1/scheduler/conf.c 2013-10-21 16:42:14.927834827 +0100
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)
*/
@ -107,9 +107,9 @@ diff -up cups-1.7rc1/scheduler/conf.c.journal cups-1.7rc1/scheduler/conf.c
cupsdCheckLogFile(&PageFile, PageLog);
/*
diff -up cups-1.7rc1/scheduler/conf.h.journal cups-1.7rc1/scheduler/conf.h
--- cups-1.7rc1/scheduler/conf.h.journal 2013-10-21 16:18:06.369038692 +0100
+++ cups-1.7rc1/scheduler/conf.h 2013-10-21 16:18:06.373038711 +0100
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);
@ -119,9 +119,9 @@ diff -up cups-1.7rc1/scheduler/conf.h.journal cups-1.7rc1/scheduler/conf.h
extern int cupsdWriteErrorLog(int level, const char *message);
diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
--- cups-1.7rc1/scheduler/job.c.journal 2013-10-21 16:18:06.371038701 +0100
+++ cups-1.7rc1/scheduler/job.c 2013-10-21 16:18:06.374038716 +0100
diff -up cups-1.7.0/scheduler/job.c.journal cups-1.7.0/scheduler/job.c
--- cups-1.7.0/scheduler/job.c.journal 2013-10-24 16:35:59.144969239 +0100
+++ cups-1.7.0/scheduler/job.c 2013-10-24 16:35:59.178969392 +0100
@@ -312,8 +312,7 @@ cupsdCheckJobs(void)
if (job->kill_time && job->kill_time <= curtime)
@ -132,7 +132,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
stop_job(job, CUPSD_JOB_FORCE);
continue;
@@ -1696,7 +1695,7 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
@@ -1699,7 +1698,7 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
* Load job attributes...
*/
@ -141,7 +141,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
snprintf(jobfile, sizeof(jobfile), "%s/c%05d", RequestRoot, job->id);
if ((fp = cupsdOpenConfFile(jobfile)) == NULL)
@@ -1704,9 +1703,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
@@ -1707,9 +1706,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
if (ippReadIO(fp, (ipp_iocb_t)cupsFileRead, 1, NULL, job->attrs) != IPP_DATA)
{
@ -153,7 +153,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
cupsFileClose(fp);
goto error;
}
@@ -1719,18 +1717,16 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
@@ -1722,18 +1720,16 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
if (!ippFindAttribute(job->attrs, "time-at-creation", IPP_TAG_INTEGER))
{
@ -176,7 +176,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
goto error;
}
@@ -1770,18 +1766,17 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
@@ -1773,18 +1769,17 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
if ((attr = ippFindAttribute(job->attrs, "job-printer-uri",
IPP_TAG_URI)) == NULL)
{
@ -200,7 +200,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
goto error;
}
@@ -1789,9 +1784,9 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
@@ -1792,9 +1787,9 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
}
else if ((destptr = cupsdFindDest(job->dest)) == NULL)
{
@ -213,7 +213,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
goto error;
}
@@ -1800,9 +1795,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
@@ -1803,9 +1798,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
{
const char *reason; /* job-state-reason keyword */
@ -225,7 +225,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
switch (job->state_value)
{
@@ -1867,9 +1861,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
@@ -1870,9 +1864,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
if ((attr = ippFindAttribute(job->attrs, "job-priority",
IPP_TAG_INTEGER)) == NULL)
{
@ -237,7 +237,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
goto error;
}
@@ -1881,9 +1874,9 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
@@ -1884,9 +1877,9 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
if ((attr = ippFindAttribute(job->attrs, "job-originating-user-name",
IPP_TAG_NAME)) == NULL)
{
@ -250,7 +250,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
goto error;
}
@@ -1928,9 +1921,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
@@ -1931,9 +1924,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
if (access(jobfile, 0))
break;
@ -262,7 +262,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
if (fileid > job->num_files)
{
@@ -1956,9 +1948,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
@@ -1959,9 +1951,8 @@ cupsdLoadJob(cupsd_job_t *job) /* I - J
if (!compressions || !filetypes)
{
@ -274,7 +274,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
ippDelete(job->attrs);
job->attrs = NULL;
@@ -2266,8 +2257,7 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
@@ -2269,8 +2260,7 @@ cupsdSaveJob(cupsd_job_t *job) /* I - J
if (ippWriteIO(fp, (ipp_iocb_t)cupsFileWrite, 1, NULL,
job->attrs) != IPP_DATA)
{
@ -284,7 +284,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
cupsFileClose(fp);
return;
}
@@ -2944,15 +2934,15 @@ dump_job_history(cupsd_job_t *job) /* I
@@ -2947,15 +2937,15 @@ dump_job_history(cupsd_job_t *job) /* I
snprintf(temp, sizeof(temp),
"[Job %d] The following messages were recorded from %s to %s",
job->id, start, end);
@ -303,7 +303,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
/*
* Log the printer state values...
@@ -2968,11 +2958,11 @@ dump_job_history(cupsd_job_t *job) /* I
@@ -2971,11 +2961,11 @@ dump_job_history(cupsd_job_t *job) /* I
printer->state == IPP_PRINTER_IDLE ? "idle" :
printer->state == IPP_PRINTER_PROCESSING ? "processing" :
"stopped");
@ -317,7 +317,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
snprintf(temp, sizeof(temp), "[Job %d] printer-state-reasons=", job->id);
ptr = temp + strlen(temp);
@@ -2991,7 +2981,7 @@ dump_job_history(cupsd_job_t *job) /* I
@@ -2994,7 +2984,7 @@ dump_job_history(cupsd_job_t *job) /* I
ptr += strlen(ptr);
}
}
@ -326,7 +326,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
}
/*
@@ -4132,8 +4122,7 @@ load_job_cache(const char *filename) /*
@@ -4135,8 +4125,7 @@ load_job_cache(const char *filename) /*
job->status_pipes[0] = -1;
job->status_pipes[1] = -1;
@ -336,7 +336,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
}
else if (!job)
{
@@ -4202,8 +4191,7 @@ load_job_cache(const char *filename) /*
@@ -4205,8 +4194,7 @@ load_job_cache(const char *filename) /*
job->id);
if (access(jobfile, 0))
{
@ -346,7 +346,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
job->num_files = 0;
continue;
}
@@ -4213,9 +4201,9 @@ load_job_cache(const char *filename) /*
@@ -4216,9 +4204,9 @@ load_job_cache(const char *filename) /*
if (!job->filetypes || !job->compressions)
{
@ -359,7 +359,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
break;
}
}
@@ -4253,9 +4241,9 @@ load_job_cache(const char *filename) /*
@@ -4256,9 +4244,9 @@ load_job_cache(const char *filename) /*
* If the original MIME type is unknown, auto-type it!
*/
@ -372,7 +372,7 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
snprintf(jobfile, sizeof(jobfile), "%s/d%05d-%03d", RequestRoot,
job->id, number + 1);
@@ -4767,7 +4755,7 @@ unload_job(cupsd_job_t *job) /* I - Job
@@ -4770,7 +4758,7 @@ unload_job(cupsd_job_t *job) /* I - Job
if (!job->attrs)
return;
@ -381,9 +381,9 @@ diff -up cups-1.7rc1/scheduler/job.c.journal cups-1.7rc1/scheduler/job.c
ippDelete(job->attrs);
diff -up cups-1.7rc1/scheduler/log.c.journal cups-1.7rc1/scheduler/log.c
--- cups-1.7rc1/scheduler/log.c.journal 2013-10-21 16:18:06.296038350 +0100
+++ cups-1.7rc1/scheduler/log.c 2013-10-21 16:31:07.826704189 +0100
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.
@ -431,7 +431,7 @@ diff -up cups-1.7rc1/scheduler/log.c.journal cups-1.7rc1/scheduler/log.c
+ return (sd_journal_send ("MESSAGE=%s", buffer,
+ "PRIORITY=%d", LOG_INFO,
+ "CUPS_JOB_ID=%d", job->id,
+ "CUPS_PAGE_NUMBER=%d", number,
+ "CUPS_PAGE_NUMBER=%s", number,
+ NULL) ? 0 : 1);
+#endif /* HAVE_JOURNAL */
+
@ -447,7 +447,7 @@ diff -up cups-1.7rc1/scheduler/log.c.journal cups-1.7rc1/scheduler/log.c
{
syslog(LOG_INFO,
"REQUEST %s - %s \"%s %s HTTP/%d.%d\" %d " CUPS_LLFMT " %s %s\n",
@@ -1017,9 +1039,11 @@ cupsdLogRequest(cupsd_client_t *con, /*
@@ -1017,8 +1039,9 @@ cupsdLogRequest(cupsd_client_t *con, /*
*/
int /* O - 1 on success, 0 on failure */
@ -457,11 +457,9 @@ diff -up cups-1.7rc1/scheduler/log.c.journal cups-1.7rc1/scheduler/log.c
+ int level, /* I - Log level */
+ const char *message) /* I - Message string */
{
+ char jobmsg[1024]; /* Format string for job message */
static const char levels[] = /* Log levels... */
{
' ',
@@ -1035,12 +1059,26 @@ cupsdWriteErrorLog(int level, /*
@@ -1035,12 +1058,25 @@ cupsdWriteErrorLog(int level, /*
};
@ -470,8 +468,7 @@ diff -up cups-1.7rc1/scheduler/log.c.journal cups-1.7rc1/scheduler/log.c
+ {
+ if (job)
+ {
+ snprintf(jobmsg, sizeof(jobmsg), "[Job %d] %s", job->id, message);
+ return (sd_journal_send ("MESSAGE=%s", jobmsg,
+ return (sd_journal_send ("MESSAGE=%s", message,
+ "PRIORITY=%d", syslevels[level],
+ "CUPS_JOB_ID=%d", job->id,
+ NULL) ? 0 : 1);
@ -489,7 +486,7 @@ diff -up cups-1.7rc1/scheduler/log.c.journal cups-1.7rc1/scheduler/log.c
{
syslog(syslevels[level], "%s", message);
return (1);
@@ -1066,6 +1104,18 @@ cupsdWriteErrorLog(int level, /*
@@ -1066,6 +1102,18 @@ cupsdWriteErrorLog(int level, /*
}