1 /* $FreeBSD: src/libexec/bootpd/report.c,v 1.2.6.2 2001/03/05 10:58:59 kris Exp $ */
4 * report() - calls syslog
22 #define LOG_BOOTP LOG_DAEMON
26 extern char *progname;
29 * This is initialized so you get stderr until you call
32 static int stderr_only = 1;
35 report_init(int nolog)
40 openlog(progname, LOG_PID | LOG_NDELAY, LOG_BOOTP);
46 * This routine reports errors and such via stderr and syslog() if
47 * appopriate. It just helps avoid a lot of "#ifdef SYSLOG" constructs
48 * from being scattered throughout the code.
50 * The syntax is identical to syslog(3), but %m is not considered special
51 * for output to stderr (i.e. you'll see "%m" in the output. . .). Also,
52 * control strings should normally end with \n since newlines aren't
53 * automatically generated for stderr output (whereas syslog strips out all
54 * newlines and adds its own at the end).
57 static char *levelnames[] = {
82 static int numlevels = sizeof(levelnames) / sizeof(levelnames[0]);
86 * Print a log message using syslog(3) and/or stderr.
87 * The message passed in should not include a newline.
90 report(int priority, const char *fmt,...)
95 if ((priority < 0) || (priority >= numlevels)) {
96 priority = numlevels - 1;
99 vsnprintf(buf, sizeof(buf), fmt, ap);
105 if (stderr_only || (debug > 2)) {
106 fprintf(stderr, "%s: %s %s\n",
107 progname, levelnames[priority], buf);
111 syslog((priority | LOG_BOOTP), "%s", buf);
118 * Return pointer to static string which gives full filesystem error message.
123 return strerror(errno);