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>
50 extern int log_priority;
53 void mr_update_com_err_hook(whoami, code, fmt, args)
59 char buf[BUFSIZ], *cp;
64 for (cp = buf; *cp; cp++)
73 strcpy(cp, error_message(code));
78 vsprintf(cp, fmt, args);
80 _strbuf._flag = _IOWRT+_IOSTRG;
82 _strbuf._cnt = BUFSIZ-(cp-buf);
83 _doprnt(fmt, args, &_strbuf);
87 syslog(syslog_prio[log_priority], "%s", buf);
94 mr_update_initialize()
96 static int initialized = 0;
100 openlog(whoami, LOG_PID, LOG_DAEMON);
102 (void) set_com_err_hook(mr_update_com_err_hook);
103 log_priority = log_INFO;
108 static char fmt[] = "[%s] %s";
110 #define def(name,level,prio) \
114 register int old_prio; \
115 old_prio = log_priority; \
116 mr_update_initialize(); \
117 com_err(whoami, 0, fmt, level, msg); \
118 log_priority = old_prio; \
121 def(mr_log_error, "error", log_ERROR)
122 def(mr_log_warning, "warning", log_WARNING)
123 def(mr_log_info, "info", log_INFO)
124 def(mr_debug, "debug", log_DEBUG)