X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Flog.c;h=31252c9ee2b0f1f083d6eb2bfb29d3b06c9a8e17;hb=31316f76dd68a03b803f51931d6e1fff2c60c5d1;hp=5a5dc808c9487ba8d479a896187678701387445f;hpb=8458dd2f239313e763dda98c8ded6e46f3f63ea4;p=libucw.git diff --git a/ucw/log.c b/ucw/log.c index 5a5dc808..31252c9e 100644 --- a/ucw/log.c +++ b/ucw/log.c @@ -45,8 +45,10 @@ struct log_stream log_stream_default = { .types = ~0U, .msgfmt = LSFMT_DEFAULT, // an empty clist - .substreams.head.next = (cnode *) &log_stream_default.substreams.head, - .substreams.head.prev = (cnode *) &log_stream_default.substreams.head, + .substreams.head = { + .next = (cnode *) &log_stream_default.substreams.head, + .prev = (cnode *) &log_stream_default.substreams.head, + }, }; /*** Registry of streams and their identifiers ***/ @@ -118,6 +120,7 @@ vmsg(uns cat, const char *fmt, va_list args) { /* CAVEAT: These calls are not safe in signal handlers. */ gettimeofday(&tv, NULL); + m.tv = &tv; if (localtime_r(&tv.tv_sec, &tm)) m.tm = &tm; } @@ -152,7 +155,7 @@ vmsg(uns cat, const char *fmt, va_list args) p = m.raw_msg; while (*p) { - if (*p < 0x20 && *p != '\t') + if (*p >= 0 && *p < 0x20 && *p != '\t') *p = 0x7f; p++; } @@ -339,18 +342,22 @@ do_die(void) } void -die(const char *fmt, ...) +vdie(const char *fmt, va_list args) { - va_list args; - - va_start(args, fmt); vmsg(L_FATAL, fmt, args); - va_end(args); if (log_die_hook) log_die_hook(); do_die(); } +void +die(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vdie(fmt, args); +} + void assert_failed(const char *assertion, const char *file, int line) {