2 * Copyright (C) 1995 Olaf Kirch
3 * Modified by Jeffrey A. Uphoff, 1995, 1997, 1999.
4 * Modified by H.J. Lu, 1998.
5 * Modified by Lon Hohberger, Oct. 2000
11 * log.c - logging functions for lockd/statd
12 * 260295 okir started with simply syslog logging.
26 #include <sys/types.h>
31 /* Turns on logging to console/stderr. */
33 static int opt_debug
= 0; /* Will be command-line option, eventually */
38 if (!(run_mode
& MODE_LOG_STDERR
))
39 openlog(name_p
, LOG_PID
| LOG_NDELAY
, LOG_DAEMON
);
43 note(N_WARNING
,"Version %s Starting",version_p
);
46 void log_background(void)
51 void die(char *fmt
, ...)
57 vsnprintf (buffer
, 1024, fmt
, ap
);
61 note(N_FATAL
, "%s", buffer
);
66 abort(); /* make a core */
70 void note(int level
, char *fmt
, ...)
76 vsnprintf (buffer
, 1024, fmt
, ap
);
80 if ((!(run_mode
& MODE_LOG_STDERR
)) && (level
< N_DEBUG
)) {
81 syslog(level
, "%s", buffer
);
82 } else if (run_mode
& MODE_LOG_STDERR
) {
83 /* Log everything, including dprintf() stuff to stderr */
89 fprintf (stderr
, "%02d/%02d/%04d %02d:%02d:%02d %s[%d]: %s\n",
90 tm
->tm_mon
+ 1, tm
->tm_mday
, tm
->tm_year
+ 1900,
91 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
,