Deleted Added
full compact
log.c (126274) log.c (137015)
1/*
2 * Author: Tatu Ylonen <ylo@cs.hut.fi>
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved
5 *
6 * As far as I am concerned, the code I have written for this software
7 * can be used freely for any purpose. Any derived versions of this
8 * software must be clearly marked as such, and if the derived work is

--- 37 unchanged lines hidden (view full) ---

46
47static LogLevel log_level = SYSLOG_LEVEL_INFO;
48static int log_on_stderr = 1;
49static int log_facility = LOG_AUTH;
50static char *argv0;
51
52extern char *__progname;
53
1/*
2 * Author: Tatu Ylonen <ylo@cs.hut.fi>
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved
5 *
6 * As far as I am concerned, the code I have written for this software
7 * can be used freely for any purpose. Any derived versions of this
8 * software must be clearly marked as such, and if the derived work is

--- 37 unchanged lines hidden (view full) ---

46
47static LogLevel log_level = SYSLOG_LEVEL_INFO;
48static int log_on_stderr = 1;
49static int log_facility = LOG_AUTH;
50static char *argv0;
51
52extern char *__progname;
53
54#define LOG_SYSLOG_VIS (VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL)
55#define LOG_STDERR_VIS (VIS_SAFE|VIS_OCTAL)
56
54/* textual representation of log-facilities/levels */
55
56static struct {
57 const char *name;
58 SyslogFacility val;
59} log_facilities[] = {
60 { "DAEMON", SYSLOG_FACILITY_DAEMON },
61 { "USER", SYSLOG_FACILITY_USER },

--- 249 unchanged lines hidden (view full) ---

311 break;
312 }
313 if (txt != NULL) {
314 snprintf(fmtbuf, sizeof(fmtbuf), "%s: %s", txt, fmt);
315 vsnprintf(msgbuf, sizeof(msgbuf), fmtbuf, args);
316 } else {
317 vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
318 }
57/* textual representation of log-facilities/levels */
58
59static struct {
60 const char *name;
61 SyslogFacility val;
62} log_facilities[] = {
63 { "DAEMON", SYSLOG_FACILITY_DAEMON },
64 { "USER", SYSLOG_FACILITY_USER },

--- 249 unchanged lines hidden (view full) ---

314 break;
315 }
316 if (txt != NULL) {
317 snprintf(fmtbuf, sizeof(fmtbuf), "%s: %s", txt, fmt);
318 vsnprintf(msgbuf, sizeof(msgbuf), fmtbuf, args);
319 } else {
320 vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
321 }
319 strnvis(fmtbuf, msgbuf, sizeof(fmtbuf), VIS_SAFE|VIS_OCTAL);
322 strnvis(fmtbuf, msgbuf, sizeof(fmtbuf),
323 log_on_stderr ? LOG_STDERR_VIS : LOG_SYSLOG_VIS);
320 if (log_on_stderr) {
321 snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf);
322 write(STDERR_FILENO, msgbuf, strlen(msgbuf));
323 } else {
324#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT)
325 openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata);
326 syslog_r(pri, &sdata, "%.500s", fmtbuf);
327 closelog_r(&sdata);
328#else
329 openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility);
330 syslog(pri, "%.500s", fmtbuf);
331 closelog();
332#endif
333 }
334}
324 if (log_on_stderr) {
325 snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf);
326 write(STDERR_FILENO, msgbuf, strlen(msgbuf));
327 } else {
328#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT)
329 openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata);
330 syslog_r(pri, &sdata, "%.500s", fmtbuf);
331 closelog_r(&sdata);
332#else
333 openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility);
334 syslog(pri, "%.500s", fmtbuf);
335 closelog();
336#endif
337 }
338}