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>
48 sms_update_com_err_hook(whoami, code, fmt, args)
54 char buf[BUFSIZ], *cp;
59 for (cp = buf; *cp; cp++)
68 strcpy(cp, error_message(code));
72 _strbuf._flag = _IOWRT+_IOSTRG;
74 _strbuf._cnt = BUFSIZ-(cp-buf);
75 _doprnt(fmt, args, &_strbuf);
78 syslog(syslog_prio[log_priority], "%s", buf);
85 sms_update_initialize()
87 static int initialized = 0;
91 openlog(whoami, LOG_PID, LOG_DAEMON);
93 (void) set_com_err_hook(sms_update_com_err_hook);
94 log_priority = log_INFO;
99 static char fmt[] = "[%s] %s";
101 #define def(name,level,prio) \
105 register int old_prio; \
106 old_prio = log_priority; \
107 sms_update_initialize(); \
108 com_err(whoami, 0, fmt, level, msg); \
109 log_priority = old_prio; \
112 def(sms_log_error, "error", log_ERROR)
113 def(sms_log_warning, "warning", log_WARNING)
114 def(sms_log_info, "info", log_INFO)
115 def(sms_debug, "debug", log_DEBUG)