summaryrefslogtreecommitdiff
path: root/scheduler/log.c
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2013-09-27 15:08:17 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2013-09-27 15:08:17 +0000
commit28a463e0280704f4d118d872115d87cb3398e6ba (patch)
tree42b1dea437493364864663e89e0511753eabf3e7 /scheduler/log.c
parent928b43f75ecc97b05c3d394af784018f6c6cc5aa (diff)
downloadcups-28a463e0280704f4d118d872115d87cb3398e6ba.tar.gz
Log power messages.
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11313 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'scheduler/log.c')
-rw-r--r--scheduler/log.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/scheduler/log.c b/scheduler/log.c
index 0d4935736..bbd858d85 100644
--- a/scheduler/log.c
+++ b/scheduler/log.c
@@ -38,6 +38,8 @@
* Local globals...
*/
+static _cups_mutex_t log_mutex = _CUPS_MUTEX_INITIALIZER;
+ /* Mutex for logging */
static int log_linesize = 0; /* Size of line for output file */
static char *log_line = NULL; /* Line for output file */
@@ -991,6 +993,7 @@ int /* O - 1 on success, 0 on failure */
cupsdWriteErrorLog(int level, /* I - Log level */
const char *message) /* I - Message string */
{
+ int ret = 1; /* Return value */
static const char levels[] = /* Log levels... */
{
' ',
@@ -1022,18 +1025,26 @@ cupsdWriteErrorLog(int level, /* I - Log level */
* Not using syslog; check the log file...
*/
+ _cupsMutexLock(&log_mutex);
+
if (!cupsdCheckLogFile(&ErrorFile, ErrorLog))
- return (0);
+ {
+ ret = 0;
+ }
+ else
+ {
+ /*
+ * Write the log message...
+ */
- /*
- * Write the log message...
- */
+ cupsFilePrintf(ErrorFile, "%c %s %s\n", levels[level],
+ cupsdGetDateTime(NULL, LogTimeFormat), message);
+ cupsFileFlush(ErrorFile);
+ }
- cupsFilePrintf(ErrorFile, "%c %s %s\n", levels[level],
- cupsdGetDateTime(NULL, LogTimeFormat), message);
- cupsFileFlush(ErrorFile);
+ _cupsMutexUnlock(&log_mutex);
- return (1);
+ return (ret);
}