X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Flog.c;h=5c4a006982f863b760e9309d34deb51eaaa05e09;hb=003ca21e49148941c07f69c87e2553f660913b65;hp=76821d981cdb73495a1a90fd59d59eeb4dd5131a;hpb=96d356a371d711395e0a39b62f8ac785739366dd;p=libucw.git diff --git a/ucw/log.c b/ucw/log.c index 76821d98..5c4a0069 100644 --- a/ucw/log.c +++ b/ucw/log.c @@ -10,6 +10,7 @@ #include "ucw/lib.h" #include "ucw/log.h" +#include "ucw/log-internal.h" #include "ucw/simple-lists.h" #include @@ -38,7 +39,7 @@ struct log_stream log_stream_default = { .name = "stderr", .use_count = 1000000, .handler = default_log_handler, - .levels = LS_ALL_LEVELS, + .levels = ~0U, .msgfmt = LSFMT_DEFAULT, // an empty clist .substreams.head.next = (cnode *) &log_stream_default.substreams.head, @@ -87,12 +88,12 @@ vmsg(uns cat, const char *fmt, va_list args) /* Check the stream existence */ if (!ls) { - msg((LS_INTERNAL_MASK&cat)|L_WARN, "No log_stream with number %d! Logging to the default log.", LS_GET_STRNUM(cat)); + msg((LS_CTRL_MASK&cat)|L_WARN, "No log_stream with number %d! Logging to the default log.", LS_GET_STRNUM(cat)); ls = &log_stream_default; } /* Get the current time */ - if (!(cat & LSFLAG_SIGHANDLER)) + if (!(cat & L_SIGHANDLER)) { /* CAVEAT: These calls are not safe in signal handlers. */ gettimeofday(&tv, NULL); @@ -158,7 +159,7 @@ log_pass_msg(int depth, struct log_stream *ls, struct log_msg *m) if (depth > LS_MAX_DEPTH) { struct log_msg errm = *m; - errm.flags = L_ERROR | (m->flags & LS_INTERNAL_MASK); + errm.flags = L_ERROR | (m->flags & LS_CTRL_MASK); errm.raw_msg = "Loop in the log_stream system detected."; log_pass_msg(0, &log_stream_default, &errm); } @@ -218,7 +219,7 @@ log_pass_msg(int depth, struct log_stream *ls, struct log_msg *m) /* Process name, PID ( |log_title| + 6 + (|PID|<=10) chars ) */ if ((ls->msgfmt & LSFMT_TITLE) && log_title) { - if (ls->msgfmt & LSFMT_PID) + if ((ls->msgfmt & LSFMT_PID) && log_pid) p += sprintf(p, "[%s (%d)] ", log_title, log_pid); else p += sprintf(p, "[%s] ", log_title); @@ -331,8 +332,11 @@ log_fork(void) int main(void) { - struct log_stream *ls = log_new_syslog(LOG_USER, "syslog"); + struct log_stream *ls = log_new_syslog("local3", 0); msg(L_INFO | ls->regnum, "Brum <%300s>", ":-)"); + log_set_format(log_default_stream(), ~0U, LSFMT_USEC); + msg(L_INFO, "Brum <%300s>", ":-)"); + log_close_all(); return 0; }