X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=errlog.c;h=58a3415e55f87fc02e1802ee14e21f3dcbe76077;hp=4fa729032d17cdfda5fa274f85b2e070c19eaabe;hb=51206131782b3cce39bdec1ffce866ece1af10ce;hpb=5f390b415777db21894f1b856ab3d21c9c24f7c6 diff --git a/errlog.c b/errlog.c index 4fa72903..58a3415e 100644 --- a/errlog.c +++ b/errlog.c @@ -1,4 +1,4 @@ -const char errlog_rcs[] = "$Id: errlog.c,v 1.20 2001/09/16 23:04:34 jongfoster Exp $"; +const char errlog_rcs[] = "$Id: errlog.c,v 1.22 2001/11/05 23:43:05 steudten Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -33,6 +33,15 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.20 2001/09/16 23:04:34 jongfoster E * * Revisions : * $Log: errlog.c,v $ + * Revision 1.22 2001/11/05 23:43:05 steudten + * Add time+date to log files. + * + * Revision 1.21 2001/10/25 03:40:47 david__schmidt + * Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple + * threads to call select() simultaneously. So, it's time to do a real, live, + * native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__ + * (native). Both versions will work, but using __OS2__ offers multi-threading. + * * Revision 1.20 2001/09/16 23:04:34 jongfoster * Fixing a warning * @@ -304,6 +313,7 @@ void log_error(int loglevel, char *fmt, ...) { va_list ap; char *outbuf= NULL; + char *outbuf_save = NULL; char * src = fmt; int outc = 0; long this_thread = 1; /* was: pthread_t this_thread;*/ @@ -340,8 +350,23 @@ void log_error(int loglevel, char *fmt, ...) this_thread = ptib -> tib_ptib2 -> tib2_ultid; #endif /* def FEATURE_PTHREAD */ - outbuf = (char*)malloc(BUFFER_SIZE); + outbuf_save = outbuf = (char*)malloc(BUFFER_SIZE); assert(outbuf); + + { + /* + * Write timestamp into tempbuf. + * + * Complex because not all OSs have tm_gmtoff or + * the %z field in strftime() + */ + time_t now; + struct tm *tm_now; + time (&now); + tm_now = localtime (&now); + strftime (outbuf, BUFFER_SIZE-6, "%b %d %H:%M:%S ", tm_now); + outbuf += strlen( outbuf ); + } switch (loglevel) { case LOG_LEVEL_ERROR: @@ -382,6 +407,7 @@ void log_error(int loglevel, char *fmt, ...) outc = sprintf(outbuf, "IJB(%ld) Gif-Deanimate: ", this_thread); break; case LOG_LEVEL_CLF: + outbuf = outbuf_save; outc = 0; outbuf[0] = '\0'; break; @@ -604,9 +630,9 @@ void log_error(int loglevel, char *fmt, ...) { logfp = stderr; } - fputs(outbuf, logfp); + fputs(outbuf_save, logfp); /* FIXME RACE HAZARD: should end critical section error_log_use here */ - fatal_error(outbuf); + fatal_error(outbuf_save); /* Never get here */ break; @@ -650,11 +676,11 @@ void log_error(int loglevel, char *fmt, ...) logfp = stderr; } - fputs(outbuf, logfp); + fputs(outbuf_save, logfp); if (loglevel == LOG_LEVEL_FATAL) { - fatal_error(outbuf); + fatal_error(outbuf_save); /* Never get here */ } @@ -662,7 +688,7 @@ void log_error(int loglevel, char *fmt, ...) #if defined(_WIN32) && !defined(_WIN_CONSOLE) /* Write to display */ - LogPutString(outbuf); + LogPutString(outbuf_save); #endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */ }