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>
28 #undef sparc /* varargs.h depends on sparc, which we use differently */
55 void mr_update_com_err_hook(whoami, code, fmt, args)
61 char buf[BUFSIZ], *cp;
66 for (cp = buf; *cp; cp++)
75 strcpy(cp, error_message(code));
80 vsprintf(cp, fmt, args);
82 _strbuf._flag = _IOWRT+_IOSTRG;
84 _strbuf._cnt = BUFSIZ-(cp-buf);
85 _doprnt(fmt, args, &_strbuf);
89 syslog(syslog_prio[log_priority], "%s", buf);
96 mr_update_initialize()
98 static int initialized = 0;
102 openlog(whoami, LOG_PID, LOG_DAEMON);
104 (void) set_com_err_hook(mr_update_com_err_hook);
105 log_priority = log_INFO;
110 static char fmt[] = "[%s] %s";
112 #define def(name,level,prio) \
116 register int old_prio; \
117 old_prio = log_priority; \
118 mr_update_initialize(); \
119 com_err(whoami, 0, fmt, level, msg); \
120 log_priority = old_prio; \
123 def(mr_log_error, "error", log_ERROR)
124 def(mr_log_warning, "warning", log_WARNING)
125 def(mr_log_info, "info", log_INFO)
126 def(mr_debug, "debug", log_DEBUG)