X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Flog-syslog.c;h=dae84005618899439df6310bbf0f923c8e071669;hb=2bc61d56ea0e8a70fb3d15a51fbfbce013c9a648;hp=dc1df456504687e35e5221e00d22a00a240e4927;hpb=e4e9c9fbf717d89be923695603d0cd5fc6c40cfa;p=libucw.git diff --git a/ucw/log-syslog.c b/ucw/log-syslog.c index dc1df456..dae84005 100644 --- a/ucw/log-syslog.c +++ b/ucw/log-syslog.c @@ -13,7 +13,11 @@ #include -/* Destructor */ +struct syslog_stream { + struct log_stream ls; + int facility; +}; + static void syslog_close(struct log_stream *ls) { @@ -21,7 +25,7 @@ syslog_close(struct log_stream *ls) xfree(ls->name); } -/* convert severity level to syslog constants */ +/* Convert severity level to syslog constants */ static int syslog_level(int level) { @@ -42,31 +46,31 @@ syslog_level(int level) static int syslog_handler(struct log_stream *ls, struct log_msg *m) { + struct syslog_stream *ss = (struct syslog_stream *) ls; int prio; ASSERT(ls); ASSERT(m); // FIXME: Logging of PID - prio = syslog_level(LS_GET_LEVEL(m->flags)) | (ls->idata); + prio = syslog_level(LS_GET_LEVEL(m->flags)) | ss->facility; if (ls->name) - syslog(prio | (ls->idata), "%s: %s", ls->name, m->m); + syslog(prio, "%s: %s", ls->name, m->m); else - syslog(prio | (ls->idata), "%s", m->m); + syslog(prio, "%s", m->m); return 0; } -/* assign log to a syslog facility */ -/* initialize with no formatting (syslog adds these inforamtion) */ -/* name is optional prefix (NULL for none) */ struct log_stream * log_new_syslog(int facility, const char *name) { - struct log_stream *ls = log_new_stream(); + struct log_stream *ls = log_new_stream(sizeof(struct syslog_stream)); + struct syslog_stream *ss = (struct syslog_stream *) ls; if (name) ls->name = xstrdup(name); - ls->idata = facility; - ls->msgfmt = LSFMT_NONE; + ls->msgfmt = 0; ls->handler = syslog_handler; ls->close = syslog_close; + ss->facility = facility; return ls; + // FIXME: L_SIGHANDLER? }