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>
52 void sms_update_com_err_hook(whoami, code, fmt, args)
58 char buf[BUFSIZ], *cp;
63 for (cp = buf; *cp; cp++)
72 strcpy(cp, error_message(code));
76 _strbuf._flag = _IOWRT+_IOSTRG;
78 _strbuf._cnt = BUFSIZ-(cp-buf);
79 _doprnt(fmt, args, &_strbuf);
82 syslog(syslog_prio[log_priority], "%s", buf);
89 sms_update_initialize()
91 static int initialized = 0;
95 openlog(whoami, LOG_PID, LOG_DAEMON);
97 (void) set_com_err_hook(sms_update_com_err_hook);
98 log_priority = log_INFO;
103 static char fmt[] = "[%s] %s";
105 #define def(name,level,prio) \
109 register int old_prio; \
110 old_prio = log_priority; \
111 sms_update_initialize(); \
112 com_err(whoami, 0, fmt, level, msg); \
113 log_priority = old_prio; \
116 def(sms_log_error, "error", log_ERROR)
117 def(sms_log_warning, "warning", log_WARNING)
118 def(sms_log_info, "info", log_INFO)
119 def(sms_debug, "debug", log_DEBUG)