2 * "$Id: log.c 7699 2008-06-27 20:44:23Z mike $"
4 * Log file routines for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2008 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * cupsdGetDateTime() - Returns a pointer to a date/time string.
18 * cupsdLogGSSMessage() - Log a GSSAPI error...
19 * cupsdLogJob() - Log a job message.
20 * cupsdLogMessage() - Log a message to the error log file.
21 * cupsdLogPage() - Log a page to the page log file.
22 * cupsdLogRequest() - Log an HTTP request in Common Log Format.
23 * cupsdWriteErrorLog() - Write a line to the ErrorLog.
24 * check_log_file() - Open/rotate a log file if it needs it.
25 * format_log_line() - Format a line for a log file.
29 * Include necessary headers...
41 static int log_linesize
= 0; /* Size of line for output file */
42 static char *log_line
= NULL
; /* Line for output file */
49 static int check_log_file(cups_file_t
**lf
, const char *logname
);
50 static int format_log_line(const char *message
, va_list ap
);
54 * 'cupsdGetDateTime()' - Returns a pointer to a date/time string.
57 char * /* O - Date/time string */
58 cupsdGetDateTime(time_t t
) /* I - Time value */
60 struct tm
*date
; /* Date/time value */
61 static time_t last_time
= -1; /* Last time value */
62 static char s
[1024]; /* Date/time string */
63 static const char * const months
[12] =/* Months */
81 * Make sure we have a valid time...
92 * Get the date and time from the UNIX time value, and then format it
93 * into a string. Note that we *can't* use the strftime() function since
94 * it is localized and will seriously confuse automatic programs if the
95 * month names are in the wrong language!
97 * Also, we use the "timezone" variable that contains the current timezone
98 * offset from GMT in seconds so that we are reporting local time in the
99 * log files. If you want GMT, set the TZ environment variable accordingly
100 * before starting the scheduler.
102 * (*BSD and Darwin store the timezone offset in the tm structure)
105 date
= localtime(&t
);
107 snprintf(s
, sizeof(s
), "[%02d/%s/%04d:%02d:%02d:%02d %+03ld%02ld]",
108 date
->tm_mday
, months
[date
->tm_mon
], 1900 + date
->tm_year
,
109 date
->tm_hour
, date
->tm_min
, date
->tm_sec
,
110 #ifdef HAVE_TM_GMTOFF
111 date
->tm_gmtoff
/ 3600, (date
->tm_gmtoff
/ 60) % 60);
113 timezone
/ 3600, (timezone
/ 60) % 60);
114 #endif /* HAVE_TM_GMTOFF */
123 * 'cupsdLogGSSMessage()' - Log a GSSAPI error...
126 int /* O - 1 on success, 0 on error */
128 int level
, /* I - Log level */
129 int major_status
, /* I - Major GSSAPI status */
130 int minor_status
, /* I - Minor GSSAPI status */
131 const char *message
, /* I - printf-style message string */
132 ...) /* I - Additional args as needed */
134 OM_uint32 err_major_status
, /* Major status code for display */
135 err_minor_status
; /* Minor status code for display */
136 OM_uint32 msg_ctx
; /* Message context */
137 gss_buffer_desc major_status_string
= GSS_C_EMPTY_BUFFER
,
138 /* Major status message */
139 minor_status_string
= GSS_C_EMPTY_BUFFER
;
140 /* Minor status message */
141 int ret
; /* Return value */
145 err_major_status
= gss_display_status(&err_minor_status
,
150 &major_status_string
);
152 if (!GSS_ERROR(err_major_status
))
153 gss_display_status(&err_minor_status
, minor_status
, GSS_C_MECH_CODE
,
154 GSS_C_NULL_OID
, &msg_ctx
, &minor_status_string
);
156 ret
= cupsdLogMessage(level
, "%s: %s, %s", message
,
157 (char *)major_status_string
.value
,
158 (char *)minor_status_string
.value
);
159 gss_release_buffer(&err_minor_status
, &major_status_string
);
160 gss_release_buffer(&err_minor_status
, &minor_status_string
);
164 #endif /* HAVE_GSSAPI */
168 * 'cupsdLogJob()' - Log a job message.
171 int /* O - 1 on success, 0 on error */
172 cupsdLogJob(cupsd_job_t
*job
, /* I - Job */
173 int level
, /* I - Log level */
174 const char *message
, /* I - Printf-style message string */
175 ...) /* I - Additional arguments as needed */
177 va_list ap
; /* Argument pointer */
178 char jobmsg
[1024]; /* Format string for job message */
179 int status
; /* Formatting status */
183 * See if we want to log this message...
186 if (TestConfigFile
|| level
> LogLevel
|| !ErrorLog
)
190 * Format and write the log message...
193 snprintf(jobmsg
, sizeof(jobmsg
), "[Job %d] %s", job
->id
, message
);
197 va_start(ap
, message
);
198 status
= format_log_line(jobmsg
, ap
);
204 return (cupsdWriteErrorLog(level
, log_line
));
206 return (cupsdWriteErrorLog(CUPSD_LOG_ERROR
,
207 "Unable to allocate memory for log line!"));
212 * 'cupsdLogMessage()' - Log a message to the error log file.
215 int /* O - 1 on success, 0 on error */
216 cupsdLogMessage(int level
, /* I - Log level */
217 const char *message
, /* I - printf-style message string */
218 ...) /* I - Additional args as needed */
220 va_list ap
; /* Argument pointer */
221 int status
; /* Formatting status */
225 * See if we want to log this message...
230 if (level
<= CUPSD_LOG_WARN
)
232 va_start(ap
, message
);
233 vfprintf(stderr
, message
, ap
);
241 if (level
> LogLevel
|| !ErrorLog
)
245 * Format and write the log message...
250 va_start(ap
, message
);
251 status
= format_log_line(message
, ap
);
257 return (cupsdWriteErrorLog(level
, log_line
));
259 return (cupsdWriteErrorLog(CUPSD_LOG_ERROR
,
260 "Unable to allocate memory for log line!"));
265 * 'cupsdLogPage()' - Log a page to the page log file.
268 int /* O - 1 on success, 0 on error */
269 cupsdLogPage(cupsd_job_t
*job
, /* I - Job being printed */
270 const char *page
) /* I - Page being printed */
272 int i
; /* Looping var */
273 char buffer
[2048], /* Buffer for page log */
274 *bufptr
, /* Pointer into buffer */
275 name
[256]; /* Attribute name */
276 const char *format
, /* Pointer into PageLogFormat */
277 *nameend
; /* End of attribute name */
278 ipp_attribute_t
*attr
; /* Current attribute */
279 int number
; /* Page number */
280 char copies
[256]; /* Number of copies */
284 * Format the line going into the page log...
292 sscanf(page
, "%d%255s", &number
, copies
);
294 for (format
= PageLogFormat
, bufptr
= buffer
; *format
; format
++)
302 case '%' : /* Literal % */
303 if (bufptr
< (buffer
+ sizeof(buffer
) - 1))
307 case 'p' : /* Printer name */
308 strlcpy(bufptr
, job
->printer
->name
,
309 sizeof(buffer
) - (bufptr
- buffer
));
310 bufptr
+= strlen(bufptr
);
313 case 'j' : /* Job ID */
314 snprintf(bufptr
, sizeof(buffer
) - (bufptr
- buffer
), "%d", job
->id
);
315 bufptr
+= strlen(bufptr
);
318 case 'u' : /* Username */
319 strlcpy(bufptr
, job
->username
? job
->username
: "-",
320 sizeof(buffer
) - (bufptr
- buffer
));
321 bufptr
+= strlen(bufptr
);
324 case 'T' : /* Date and time */
325 strlcpy(bufptr
, cupsdGetDateTime(time(NULL
)),
326 sizeof(buffer
) - (bufptr
- buffer
));
327 bufptr
+= strlen(bufptr
);
330 case 'P' : /* Page number */
331 snprintf(bufptr
, sizeof(buffer
) - (bufptr
- buffer
), "%d", number
);
332 bufptr
+= strlen(bufptr
);
335 case 'C' : /* Number of copies */
336 strlcpy(bufptr
, copies
, sizeof(buffer
) - (bufptr
- buffer
));
337 bufptr
+= strlen(bufptr
);
340 case '{' : /* {attribute} */
341 if ((nameend
= strchr(format
, '}')) != NULL
&&
342 (nameend
- format
- 2) < (sizeof(name
) - 1))
345 * Pull the name from inside the brackets...
348 memcpy(name
, format
+ 1, nameend
- format
- 1);
349 name
[nameend
- format
- 1] = '\0';
353 if ((attr
= ippFindAttribute(job
->attrs
, name
,
354 IPP_TAG_ZERO
)) != NULL
)
357 * Add the attribute value...
361 i
< attr
->num_values
&&
362 bufptr
< (buffer
+ sizeof(buffer
) - 1);
368 switch (attr
->value_tag
)
370 case IPP_TAG_INTEGER
:
372 snprintf(bufptr
, sizeof(buffer
) - (bufptr
- buffer
),
373 "%d", attr
->values
[i
].integer
);
374 bufptr
+= strlen(bufptr
);
377 case IPP_TAG_BOOLEAN
:
378 snprintf(bufptr
, sizeof(buffer
) - (bufptr
- buffer
),
379 "%d", attr
->values
[i
].boolean
);
380 bufptr
+= strlen(bufptr
);
383 case IPP_TAG_TEXTLANG
:
384 case IPP_TAG_NAMELANG
:
387 case IPP_TAG_KEYWORD
:
389 case IPP_TAG_URISCHEME
:
390 case IPP_TAG_CHARSET
:
391 case IPP_TAG_LANGUAGE
:
392 case IPP_TAG_MIMETYPE
:
393 strlcpy(bufptr
, attr
->values
[i
].string
.text
,
394 sizeof(buffer
) - (bufptr
- buffer
));
395 bufptr
+= strlen(bufptr
);
399 strlcpy(bufptr
, "???",
400 sizeof(buffer
) - (bufptr
- buffer
));
401 bufptr
+= strlen(bufptr
);
406 else if (bufptr
< (buffer
+ sizeof(buffer
) - 1))
412 if (bufptr
< (buffer
+ sizeof(buffer
) - 2))
420 else if (bufptr
< (buffer
+ sizeof(buffer
) - 1))
428 * See if we are logging pages via syslog...
431 if (!strcmp(PageLog
, "syslog"))
433 syslog(LOG_INFO
, "%s", buffer
);
437 #endif /* HAVE_VSYSLOG */
440 * Not using syslog; check the log file...
443 if (!check_log_file(&PageFile
, PageLog
))
447 * Print a page log entry of the form:
449 * printer user job-id [DD/MON/YYYY:HH:MM:SS +TTTT] page num-copies \
453 cupsFilePrintf(PageFile
, "%s\n", buffer
);
454 cupsFileFlush(PageFile
);
461 * 'cupsdLogRequest()' - Log an HTTP request in Common Log Format.
464 int /* O - 1 on success, 0 on error */
465 cupsdLogRequest(cupsd_client_t
*con
, /* I - Request to log */
466 http_status_t code
) /* I - Response code */
468 char temp
[2048]; /* Temporary string for URI */
469 static const char * const states
[] = /* HTTP client states... */
489 * Filter requests as needed...
492 if (AccessLogLevel
< CUPSD_ACCESSLOG_ALL
)
495 * Eliminate simple GET requests...
498 if ((con
->operation
== HTTP_GET
&&
499 strncmp(con
->uri
, "/admin/conf", 11) &&
500 strncmp(con
->uri
, "/admin/log", 10)) ||
501 (con
->operation
== HTTP_POST
&& !con
->request
&&
502 strncmp(con
->uri
, "/admin", 6)) ||
503 (con
->operation
!= HTTP_POST
&& con
->operation
!= HTTP_PUT
))
506 if (con
->request
&& con
->response
&&
507 con
->response
->request
.status
.status_code
< IPP_REDIRECTION_OTHER_SITE
)
510 * Check successful requests...
513 ipp_op_t op
= con
->request
->request
.op
.operation_id
;
514 static cupsd_accesslog_t standard_ops
[] =
516 CUPSD_ACCESSLOG_ALL
, /* reserved */
517 CUPSD_ACCESSLOG_ALL
, /* reserved */
518 CUPSD_ACCESSLOG_ACTIONS
,/* Print-Job */
519 CUPSD_ACCESSLOG_ACTIONS
,/* Print-URI */
520 CUPSD_ACCESSLOG_ACTIONS
,/* Validate-Job */
521 CUPSD_ACCESSLOG_ACTIONS
,/* Create-Job */
522 CUPSD_ACCESSLOG_ACTIONS
,/* Send-Document */
523 CUPSD_ACCESSLOG_ACTIONS
,/* Send-URI */
524 CUPSD_ACCESSLOG_ACTIONS
,/* Cancel-Job */
525 CUPSD_ACCESSLOG_ALL
, /* Get-Job-Attributes */
526 CUPSD_ACCESSLOG_ALL
, /* Get-Jobs */
527 CUPSD_ACCESSLOG_ALL
, /* Get-Printer-Attributes */
528 CUPSD_ACCESSLOG_ACTIONS
,/* Hold-Job */
529 CUPSD_ACCESSLOG_ACTIONS
,/* Release-Job */
530 CUPSD_ACCESSLOG_ACTIONS
,/* Restart-Job */
531 CUPSD_ACCESSLOG_ALL
, /* reserved */
532 CUPSD_ACCESSLOG_CONFIG
, /* Pause-Printer */
533 CUPSD_ACCESSLOG_CONFIG
, /* Resume-Printer */
534 CUPSD_ACCESSLOG_CONFIG
, /* Purge-Jobs */
535 CUPSD_ACCESSLOG_CONFIG
, /* Set-Printer-Attributes */
536 CUPSD_ACCESSLOG_ACTIONS
,/* Set-Job-Attributes */
537 CUPSD_ACCESSLOG_CONFIG
, /* Get-Printer-Supported-Values */
538 CUPSD_ACCESSLOG_ACTIONS
,/* Create-Printer-Subscription */
539 CUPSD_ACCESSLOG_ACTIONS
,/* Create-Job-Subscription */
540 CUPSD_ACCESSLOG_ALL
, /* Get-Subscription-Attributes */
541 CUPSD_ACCESSLOG_ALL
, /* Get-Subscriptions */
542 CUPSD_ACCESSLOG_ACTIONS
,/* Renew-Subscription */
543 CUPSD_ACCESSLOG_ACTIONS
,/* Cancel-Subscription */
544 CUPSD_ACCESSLOG_ALL
, /* Get-Notifications */
545 CUPSD_ACCESSLOG_ACTIONS
,/* Send-Notifications */
546 CUPSD_ACCESSLOG_ALL
, /* reserved */
547 CUPSD_ACCESSLOG_ALL
, /* reserved */
548 CUPSD_ACCESSLOG_ALL
, /* reserved */
549 CUPSD_ACCESSLOG_ALL
, /* Get-Print-Support-Files */
550 CUPSD_ACCESSLOG_CONFIG
, /* Enable-Printer */
551 CUPSD_ACCESSLOG_CONFIG
, /* Disable-Printer */
552 CUPSD_ACCESSLOG_CONFIG
, /* Pause-Printer-After-Current-Job */
553 CUPSD_ACCESSLOG_ACTIONS
,/* Hold-New-Jobs */
554 CUPSD_ACCESSLOG_ACTIONS
,/* Release-Held-New-Jobs */
555 CUPSD_ACCESSLOG_CONFIG
, /* Deactivate-Printer */
556 CUPSD_ACCESSLOG_CONFIG
, /* Activate-Printer */
557 CUPSD_ACCESSLOG_CONFIG
, /* Restart-Printer */
558 CUPSD_ACCESSLOG_CONFIG
, /* Shutdown-Printer */
559 CUPSD_ACCESSLOG_CONFIG
, /* Startup-Printer */
560 CUPSD_ACCESSLOG_ACTIONS
,/* Reprocess-Job */
561 CUPSD_ACCESSLOG_ACTIONS
,/* Cancel-Current-Job */
562 CUPSD_ACCESSLOG_ACTIONS
,/* Suspend-Current-Job */
563 CUPSD_ACCESSLOG_ACTIONS
,/* Resume-Job */
564 CUPSD_ACCESSLOG_ACTIONS
,/* Promote-Job */
565 CUPSD_ACCESSLOG_ACTIONS
/* Schedule-Job-After */
567 static cupsd_accesslog_t cups_ops
[] =
569 CUPSD_ACCESSLOG_ALL
, /* CUPS-Get-Default */
570 CUPSD_ACCESSLOG_ALL
, /* CUPS-Get-Printers */
571 CUPSD_ACCESSLOG_CONFIG
, /* CUPS-Add-Modify-Printer */
572 CUPSD_ACCESSLOG_CONFIG
, /* CUPS-Delete-Printer */
573 CUPSD_ACCESSLOG_ALL
, /* CUPS-Get-Classes */
574 CUPSD_ACCESSLOG_CONFIG
, /* CUPS-Add-Modify-Class */
575 CUPSD_ACCESSLOG_CONFIG
, /* CUPS-Delete-Class */
576 CUPSD_ACCESSLOG_CONFIG
, /* CUPS-Accept-Jobs */
577 CUPSD_ACCESSLOG_CONFIG
, /* CUPS-Reject-Jobs */
578 CUPSD_ACCESSLOG_CONFIG
, /* CUPS-Set-Default */
579 CUPSD_ACCESSLOG_CONFIG
, /* CUPS-Get-Devices */
580 CUPSD_ACCESSLOG_CONFIG
, /* CUPS-Get-PPDs */
581 CUPSD_ACCESSLOG_ACTIONS
,/* CUPS-Move-Job */
582 CUPSD_ACCESSLOG_ACTIONS
,/* CUPS-Authenticate-Job */
583 CUPSD_ACCESSLOG_ALL
/* CUPS-Get-PPD */
587 if ((op
<= IPP_SCHEDULE_JOB_AFTER
&& standard_ops
[op
] > AccessLogLevel
) ||
588 (op
>= CUPS_GET_DEFAULT
&& op
<= CUPS_GET_PPD
&&
589 cups_ops
[op
- CUPS_GET_DEFAULT
] > AccessLogLevel
))
596 * See if we are logging accesses via syslog...
599 if (!strcmp(AccessLog
, "syslog"))
602 "REQUEST %s - %s \"%s %s HTTP/%d.%d\" %d " CUPS_LLFMT
" %s %s\n",
603 con
->http
.hostname
, con
->username
[0] != '\0' ? con
->username
: "-",
604 states
[con
->operation
], _httpEncodeURI(temp
, con
->uri
, sizeof(temp
)),
605 con
->http
.version
/ 100, con
->http
.version
% 100,
606 code
, CUPS_LLCAST con
->bytes
,
608 ippOpString(con
->request
->request
.op
.operation_id
) : "-",
610 ippErrorString(con
->response
->request
.status
.status_code
) : "-");
614 #endif /* HAVE_VSYSLOG */
617 * Not using syslog; check the log file...
620 if (!check_log_file(&AccessFile
, AccessLog
))
624 * Write a log of the request in "common log format"...
627 cupsFilePrintf(AccessFile
,
628 "%s - %s %s \"%s %s HTTP/%d.%d\" %d " CUPS_LLFMT
" %s %s\n",
629 con
->http
.hostname
, con
->username
[0] != '\0' ? con
->username
: "-",
630 cupsdGetDateTime(con
->start
), states
[con
->operation
],
631 _httpEncodeURI(temp
, con
->uri
, sizeof(temp
)),
632 con
->http
.version
/ 100, con
->http
.version
% 100,
633 code
, CUPS_LLCAST con
->bytes
,
635 ippOpString(con
->request
->request
.op
.operation_id
) : "-",
637 ippErrorString(con
->response
->request
.status
.status_code
) :
640 cupsFileFlush(AccessFile
);
647 * 'cupsdWriteErrorLog()' - Write a line to the ErrorLog.
650 int /* O - 1 on success, 0 on failure */
651 cupsdWriteErrorLog(int level
, /* I - Log level */
652 const char *message
) /* I - Message string */
654 static const char levels
[] = /* Log levels... */
668 static const int syslevels
[] = /* SYSLOG levels... */
681 #endif /* HAVE_VSYSLOG */
686 * See if we are logging errors via syslog...
689 if (!strcmp(ErrorLog
, "syslog"))
691 syslog(syslevels
[level
], "%s", message
);
694 #endif /* HAVE_VSYSLOG */
697 * Not using syslog; check the log file...
700 if (!check_log_file(&ErrorFile
, ErrorLog
))
704 * Write the log message...
707 cupsFilePrintf(ErrorFile
, "%c %s %s\n", levels
[level
],
708 cupsdGetDateTime(time(NULL
)), message
);
709 cupsFileFlush(ErrorFile
);
716 * 'check_log_file()' - Open/rotate a log file if it needs it.
719 static int /* O - 1 if log file open */
720 check_log_file(cups_file_t
**lf
, /* IO - Log file */
721 const char *logname
) /* I - Log filename */
723 char backname
[1024], /* Backup log filename */
724 filename
[1024], /* Formatted log filename */
725 *ptr
; /* Pointer into filename */
726 const char *logptr
; /* Pointer into log filename */
730 * See if we have a log file to check...
733 if (!lf
|| !logname
|| !logname
[0])
737 * Format the filename as needed...
741 (strncmp(logname
, "/dev/", 5) && cupsFileTell(*lf
) > MaxLogSize
&&
745 * Handle format strings...
748 filename
[sizeof(filename
) - 1] = '\0';
750 if (logname
[0] != '/')
752 strlcpy(filename
, ServerRoot
, sizeof(filename
));
753 strlcat(filename
, "/", sizeof(filename
));
758 for (logptr
= logname
, ptr
= filename
+ strlen(filename
);
759 *logptr
&& ptr
< (filename
+ sizeof(filename
) - 1);
771 * Insert the server name...
774 strlcpy(ptr
, ServerName
, sizeof(filename
) - (ptr
- filename
));
780 * Otherwise just insert the character...
793 * See if the log file is open...
799 * Nope, open the log file...
802 if ((*lf
= cupsFileOpen(filename
, "a")) == NULL
)
805 * If the file is in CUPS_LOGDIR then try to create a missing directory...
808 if (!strncmp(filename
, CUPS_LOGDIR
, strlen(CUPS_LOGDIR
)))
811 * Try updating the permissions of the containing log directory, using
812 * the log file permissions as a basis...
815 int log_dir_perm
= 0300 | LogFilePerm
;
816 /* LogFilePerm + owner write/search */
817 if (log_dir_perm
& 0040)
818 log_dir_perm
|= 0010; /* Add group search */
819 if (log_dir_perm
& 0004)
820 log_dir_perm
|= 0001; /* Add other search */
822 cupsdCheckPermissions(CUPS_LOGDIR
, NULL
, log_dir_perm
, RunUser
, Group
,
825 *lf
= cupsFileOpen(filename
, "a");
830 syslog(LOG_ERR
, "Unable to open log file \"%s\" - %s", filename
,
833 if (FatalErrors
& CUPSD_FATAL_LOG
)
834 cupsdEndProcess(getpid(), 0);
840 if (strncmp(filename
, "/dev/", 5))
843 * Change ownership and permissions of non-device logs...
846 fchown(cupsFileNumber(*lf
), RunUser
, Group
);
847 fchmod(cupsFileNumber(*lf
), LogFilePerm
);
852 * Do we need to rotate the log?
855 if (strncmp(logname
, "/dev/", 5) && cupsFileTell(*lf
) > MaxLogSize
&&
864 strcpy(backname
, filename
);
865 strlcat(backname
, ".O", sizeof(backname
));
868 rename(filename
, backname
);
870 if ((*lf
= cupsFileOpen(filename
, "a")) == NULL
)
872 syslog(LOG_ERR
, "Unable to open log file \"%s\" - %s", filename
,
875 if (FatalErrors
& CUPSD_FATAL_LOG
)
876 cupsdEndProcess(getpid(), 0);
882 * Change ownership and permissions of non-device logs...
885 fchown(cupsFileNumber(*lf
), RunUser
, Group
);
886 fchmod(cupsFileNumber(*lf
), LogFilePerm
);
894 * 'format_log_line()' - Format a line for a log file.
896 * This function resizes a global string buffer as needed. Each call returns
897 * a pointer to this buffer, so the contents are only good until the next call
898 * to format_log_line()...
901 static int /* O - -1 for fatal, 0 for retry, 1 for success */
902 format_log_line(const char *message
, /* I - Printf-style format string */
903 va_list ap
) /* I - Argument list */
905 int len
; /* Length of formatted line */
909 * Allocate the line buffer as needed...
915 log_line
= malloc(log_linesize
);
922 * Format the log message...
925 len
= vsnprintf(log_line
, log_linesize
, message
, ap
);
928 * Resize the buffer as needed...
931 if (len
>= log_linesize
)
933 char *temp
; /* Temporary string pointer */
940 else if (len
> 65536)
943 temp
= realloc(log_line
, len
);
959 * End of "$Id: log.c 7699 2008-06-27 20:44:23Z mike $".