]> andersk Git - moira.git/blame - update/log.c
Allow numbers, '_' and '.' in usernames.
[moira.git] / update / log.c
CommitLineData
de56407f 1/*
2 * $Source$
3 * $Header$
4 */
5
6#ifndef lint
7static char *rcsid_log_c = "$Header$";
8#endif lint
9
10/*
11 * handle logging for dcm and update server
12 *
13 * this should eventually use zephyr
14 */
15
16/*
17 * define syslog for using syslog,
18 * default to tty
19 */
20#define use_syslog
21
22#include <stdio.h>
23#include "com_err.h"
24#include <varargs.h>
25#include "update.h"
26#include <krb.h>
27
28#ifdef use_syslog
29#include <syslog.h>
30#else
31#define use_tty
32#endif
33
34#ifdef use_syslog
35int syslog_prio[] = {
36 LOG_DEBUG,
37 LOG_INFO,
38 LOG_WARNING,
39 LOG_ERR
40};
41#endif
42int log_priority;
43
44sms_update_com_err_hook(whoami, code, fmt, args)
45 char *whoami;
46 int code;
47 char *fmt;
48 va_list args;
49{
50 char buf[BUFSIZ], *cp;
51 FILE _strbuf;
52
53#ifndef use_syslog
54 strcpy(buf, whoami);
55 for (cp = buf; *cp; cp++)
56 ;
57 *cp++ = ':';
58 *cp++ = ' ';
59#else
60 cp = buf;
61 *cp = '\0';
62#endif
63 if (code) {
64 strcpy(cp, error_message(code));
65 while (*cp)
66 cp++;
67 }
68 _strbuf._flag = _IOWRT+_IOSTRG;
69 _strbuf._ptr = cp;
70 _strbuf._cnt = BUFSIZ-(cp-buf);
71 _doprnt(fmt, args, &_strbuf);
72 putc('\0', &_strbuf);
73#ifdef use_syslog
74 syslog(syslog_prio[log_priority], "%s", buf);
75#endif
76#ifdef use_tty
77 puts(buf);
78#endif
79}
80
81sms_update_initialize()
82{
83 static int initialized = 0;
84 if (initialized)
85 return;
86#ifdef use_syslog
87 openlog(whoami, LOG_PID, LOG_DAEMON);
88#endif
89 (void) set_com_err_hook(sms_update_com_err_hook);
90 log_priority = log_INFO;
91 initialized = 1;
92}
This page took 0.062665 seconds and 5 git commands to generate.