Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nfs-utils / utils / statd / log.c
bloba6ca996b6b81117f4d5db24de6e04f8bf1e744f6
1 /*
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
7 * NSM for Linux.
8 */
10 /*
11 * log.c - logging functions for lockd/statd
12 * 260295 okir started with simply syslog logging.
15 #ifdef HAVE_CONFIG_H
16 #include <config.h>
17 #endif
19 #include <syslog.h>
20 #include <unistd.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <stdarg.h>
25 #include <time.h>
26 #include <sys/types.h>
27 #include "log.h"
28 #include "statd.h"
30 static pid_t mypid;
31 /* Turns on logging to console/stderr. */
32 #if 0
33 static int opt_debug = 0; /* Will be command-line option, eventually */
34 #endif
36 void log_init(void)
38 if (!(run_mode & MODE_LOG_STDERR))
39 openlog(name_p, LOG_PID | LOG_NDELAY, LOG_DAEMON);
41 mypid = getpid();
43 note(N_WARNING,"Version %s Starting",version_p);
46 void log_background(void)
48 /* NOP */
51 void die(char *fmt, ...)
53 char buffer[1024];
54 va_list ap;
56 va_start(ap, fmt);
57 vsnprintf (buffer, 1024, fmt, ap);
58 va_end(ap);
59 buffer[1023]=0;
61 note(N_FATAL, "%s", buffer);
63 #ifndef DEBUG
64 exit (2);
65 #else
66 abort(); /* make a core */
67 #endif
70 void note(int level, char *fmt, ...)
72 char buffer[1024];
73 va_list ap;
75 va_start(ap, fmt);
76 vsnprintf (buffer, 1024, fmt, ap);
77 va_end(ap);
78 buffer[1023]=0;
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 */
84 time_t now;
85 struct tm * tm;
87 time(&now);
88 tm = localtime(&now);
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,
92 name_p, mypid,
93 buffer);