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.
24 #include <sys/types.h>
29 /* Turns on logging to console/stderr. */
30 static int opt_debug = 0; /* Will be command-line option, eventually */
34 if (!(run_mode & MODE_LOG_STDERR))
35 openlog(name_p, LOG_PID | LOG_NDELAY, LOG_DAEMON);
39 note(N_WARNING,"Version %s Starting",version_p);
42 void log_background(void)
47 void die(char *fmt, ...)
53 vsnprintf (buffer, 1024, fmt, ap);
57 note(N_FATAL, "%s", buffer);
62 abort(); /* make a core */
66 void note(int level, char *fmt, ...)
72 vsnprintf (buffer, 1024, fmt, ap);
76 if ((!(run_mode & MODE_LOG_STDERR)) && (level < N_DEBUG)) {
77 syslog(level, "%s", buffer);
78 } else if (run_mode & MODE_LOG_STDERR) {
79 /* Log everything, including dprintf() stuff to stderr */
85 fprintf (stderr, "%02d/%02d/%04d %02d:%02d:%02d %s[%d]: %s\n",
86 tm->tm_mon + 1, tm->tm_mday, tm->tm_year + 1900,
87 tm->tm_hour, tm->tm_min, tm->tm_sec,