5 /* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
6 /* For copying and distribution information, please see the file */
7 /* <mit-copyright.h>. */
10 static char *rcsid_log_c = "$Header$";
14 * handle logging for dcm and update server
16 * this should eventually use zephyr
20 * define syslog for using syslog,
24 #include <mit-copyright.h>
45 extern int log_priority;
48 void mr_update_com_err_hook(const char *whoami, long code,
49 const char *fmt, va_list args)
51 char buf[BUFSIZ], *cp;
56 for (cp = buf; *cp; cp++)
66 strcpy(cp, error_message(code));
70 vsprintf(cp, fmt, args);
72 syslog(syslog_prio[log_priority], "%s", buf);
79 mr_update_initialize(void)
81 static int initialized = 0;
85 openlog(whoami, LOG_PID, LOG_DAEMON);
87 set_com_err_hook(mr_update_com_err_hook);
88 log_priority = log_INFO;
93 static char fmt[] = "[%s] %s";
95 #define def(name, level, prio) \
99 old_prio = log_priority; \
100 mr_update_initialize(); \
101 com_err(whoami, 0, fmt, level, msg); \
102 log_priority = old_prio; \
105 def(mr_log_error, "error", log_ERROR)
106 def(mr_log_warning, "warning", log_WARNING)
107 def(mr_log_info, "info", log_INFO)
108 def(mr_debug, "debug", log_DEBUG)