diff options
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 23 |
1 files changed, 6 insertions, 17 deletions
@@ -34,15 +34,12 @@ | |||
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include "includes.h" | 36 | #include "includes.h" |
37 | RCSID("$OpenBSD: log.c,v 1.28 2003/05/24 09:02:22 djm Exp $"); | 37 | RCSID("$OpenBSD: log.c,v 1.25 2003/01/11 18:29:43 markus Exp $"); |
38 | 38 | ||
39 | #include "log.h" | 39 | #include "log.h" |
40 | #include "xmalloc.h" | 40 | #include "xmalloc.h" |
41 | 41 | ||
42 | #include <syslog.h> | 42 | #include <syslog.h> |
43 | #if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) | ||
44 | # include <vis.h> | ||
45 | #endif | ||
46 | 43 | ||
47 | static LogLevel log_level = SYSLOG_LEVEL_INFO; | 44 | static LogLevel log_level = SYSLOG_LEVEL_INFO; |
48 | static int log_on_stderr = 1; | 45 | static int log_on_stderr = 1; |
@@ -131,7 +128,7 @@ error(const char *fmt,...) | |||
131 | /* Log this message (information that usually should go to the log). */ | 128 | /* Log this message (information that usually should go to the log). */ |
132 | 129 | ||
133 | void | 130 | void |
134 | logit(const char *fmt,...) | 131 | log(const char *fmt,...) |
135 | { | 132 | { |
136 | va_list args; | 133 | va_list args; |
137 | 134 | ||
@@ -344,9 +341,6 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) | |||
344 | void | 341 | void |
345 | do_log(LogLevel level, const char *fmt, va_list args) | 342 | do_log(LogLevel level, const char *fmt, va_list args) |
346 | { | 343 | { |
347 | #ifdef OPENLOG_R | ||
348 | struct syslog_data sdata = SYSLOG_DATA_INIT; | ||
349 | #endif | ||
350 | char msgbuf[MSGBUFSIZ]; | 344 | char msgbuf[MSGBUFSIZ]; |
351 | char fmtbuf[MSGBUFSIZ]; | 345 | char fmtbuf[MSGBUFSIZ]; |
352 | char *txt = NULL; | 346 | char *txt = NULL; |
@@ -395,19 +389,14 @@ do_log(LogLevel level, const char *fmt, va_list args) | |||
395 | } else { | 389 | } else { |
396 | vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); | 390 | vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); |
397 | } | 391 | } |
398 | strnvis(fmtbuf, msgbuf, sizeof(fmtbuf), VIS_SAFE|VIS_OCTAL); | 392 | /* Escape magic chars in output. */ |
393 | strnvis(fmtbuf, msgbuf, sizeof(fmtbuf), VIS_OCTAL); | ||
394 | |||
399 | if (log_on_stderr) { | 395 | if (log_on_stderr) { |
400 | snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf); | 396 | fprintf(stderr, "%s\r\n", fmtbuf); |
401 | write(STDERR_FILENO, msgbuf, strlen(msgbuf)); | ||
402 | } else { | 397 | } else { |
403 | #ifdef OPENLOG_R | ||
404 | openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata); | ||
405 | syslog_r(pri, &sdata, "%.500s", fmtbuf); | ||
406 | closelog_r(&sdata); | ||
407 | #else | ||
408 | openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility); | 398 | openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility); |
409 | syslog(pri, "%.500s", fmtbuf); | 399 | syslog(pri, "%.500s", fmtbuf); |
410 | closelog(); | 400 | closelog(); |
411 | #endif | ||
412 | } | 401 | } |
413 | } | 402 | } |