4 * report() - calls syslog
23 #define LOG_BOOTP LOG_DAEMON
27 extern char *progname;
30 * This is initialized so you get stderr until you call
33 static int stderr_only = 1;
42 openlog(progname, LOG_PID | LOG_NDELAY, LOG_BOOTP);
48 * This routine reports errors and such via stderr and syslog() if
49 * appopriate. It just helps avoid a lot of "#ifdef SYSLOG" constructs
50 * from being scattered throughout the code.
52 * The syntax is identical to syslog(3), but %m is not considered special
53 * for output to stderr (i.e. you'll see "%m" in the output. . .). Also,
54 * control strings should normally end with \n since newlines aren't
55 * automatically generated for stderr output (whereas syslog strips out all
56 * newlines and adds its own at the end).
59 static char *levelnames[] = {
84 static int numlevels = sizeof(levelnames) / sizeof(levelnames[0]);
88 * Print a log message using syslog(3) and/or stderr.
89 * The message passed in should not include a newline.
92 report(int priority, const char *fmt,...)
97 if ((priority < 0) || (priority >= numlevels)) {
98 priority = numlevels - 1;
101 vsnprintf(buf, sizeof(buf), fmt, ap);
107 if (stderr_only || (debug > 2)) {
108 fprintf(stderr, "%s: %s %s\n",
109 progname, levelnames[priority], buf);
113 syslog((priority | LOG_BOOTP), "%s", buf);
120 * Return pointer to static string which gives full filesystem error message.
125 return strerror(errno);
132 * c-argdecl-indent: 4
133 * c-continued-statement-offset: 4
134 * c-continued-brace-offset: -4