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 mr_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 #if defined(AIX386) || defined(sun)
77 vsprintf(cp, fmt, args);
79 _strbuf._flag = _IOWRT+_IOSTRG;
81 _strbuf._cnt = BUFSIZ-(cp-buf);
82 _doprnt(fmt, args, &_strbuf);
86 syslog(syslog_prio[log_priority], "%s", buf);
93 mr_update_initialize()
95 static int initialized = 0;
99 openlog(whoami, LOG_PID, LOG_DAEMON);
101 (void) set_com_err_hook(mr_update_com_err_hook);
102 log_priority = log_INFO;
107 static char fmt[] = "[%s] %s";
109 #define def(name,level,prio) \
113 register int old_prio; \
114 old_prio = log_priority; \
115 mr_update_initialize(); \
116 com_err(whoami, 0, fmt, level, msg); \
117 log_priority = old_prio; \
120 def(mr_log_error, "error", log_ERROR)
121 def(mr_log_warning, "warning", log_WARNING)
122 def(mr_log_info, "info", log_INFO)
123 def(mr_debug, "debug", log_DEBUG)