X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Flog.c;h=351c0bd1a82e35702ddd321024513b967a1b3f8b;hp=2708bb457c1222d3118a01e33321a34b5c1b1229;hb=021f5586a328c6600460aa9f9be664ba19ba20d4;hpb=8d691989077a0addcbd840d769dce6700f3d9622 diff --git a/src/log.c b/src/log.c index 2708bb4..351c0bd 100644 --- a/src/log.c +++ b/src/log.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: log.c,v 1.45 2007-01-03 08:42:15 adam Exp $ + * $Id: log.c,v 1.48 2007-02-23 10:15:01 adam Exp $ */ /** @@ -36,6 +36,7 @@ #include #include #include +#include #include static NMEM_MUTEX log_mutex = 0; @@ -388,7 +389,7 @@ static void yaz_strftime(char *dst, size_t sz, #ifdef WIN32 DWORD tid = GetCurrentThreadId(); #else - long tid = 0; + pthread_t tid = 0; #if YAZ_POSIX_THREADS tid = pthread_self(); #endif @@ -444,14 +445,16 @@ static void yaz_log_to_file(int level, const char *log_message) level &= ~mask_names[i].mask; } } - - if (l_level & YLOG_NOTIME) - tbuf[0] = '\0'; - else - yaz_strftime(tbuf, TIMEFORMAT_LEN-1, l_actual_format, tm); - tbuf[TIMEFORMAT_LEN-1] = '\0'; - - fprintf(file, "%s %s%s %s%s\n", tbuf, l_prefix, flags, l_prefix2, + + tbuf[0] = '\0'; + if (!(l_level & YLOG_NOTIME)) + { + yaz_strftime(tbuf, TIMEFORMAT_LEN-2, l_actual_format, tm); + tbuf[TIMEFORMAT_LEN-2] = '\0'; + } + if (tbuf[0]) + strcat(tbuf, " "); + fprintf(file, "%s%s%s %s%s\n", tbuf, l_prefix, flags, l_prefix2, log_message); if (l_level & YLOG_FLUSH) fflush(file); @@ -470,17 +473,8 @@ void yaz_log(int level, const char *fmt, ...) if (!(level & l_level)) return; va_start(ap, fmt); -#ifdef WIN32 - _vsnprintf(buf, sizeof(buf)-1, fmt, ap); -#else -/* !WIN32 */ -#if HAVE_VSNPRINTF - vsnprintf(buf, sizeof(buf), fmt, ap); -#else - vsprintf(buf, fmt, ap); -#endif -#endif -/* WIN32 */ + + yaz_vsnprintf(buf, sizeof(buf)-1, fmt, ap); if (o_level & YLOG_ERRNO) { strcat(buf, " [");