From: steudten Date: Mon, 5 Nov 2001 23:43:05 +0000 (+0000) Subject: Add time+date to log files. X-Git-Tag: v_2_9_10~41 X-Git-Url: http://www.privoxy.org/gitweb/contact.html?a=commitdiff_plain;h=2f86c770ec87c33518b40e47e229ab8cd813853a;p=privoxy.git Add time+date to log files. --- diff --git a/errlog.c b/errlog.c index 4fa72903..739736ce 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.21 2001/10/25 03:40:47 david__schmidt Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -33,6 +33,12 @@ 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.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 +310,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 +347,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: @@ -604,9 +626,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 +672,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 +684,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) */ } diff --git a/parsers.c b/parsers.c index e531ea16..5445cc57 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.39 2001/10/26 17:40:04 oes Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.40 2001/10/26 20:13:09 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -41,6 +41,9 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.39 2001/10/26 17:40:04 oes Exp $" * * Revisions : * $Log: parsers.c,v $ + * Revision 1.40 2001/10/26 20:13:09 jongfoster + * ctype.h is needed in Windows, too. + * * Revision 1.39 2001/10/26 17:40:04 oes * Introduced get_header_value() * Removed http->user_agent, csp->referrer and csp->accept_types @@ -1642,9 +1645,23 @@ char *server_http(const struct parsers *v, const char *s, struct client_state *c char *server_set_cookie(const struct parsers *v, const char *s, struct client_state *csp) { #ifdef FEATURE_COOKIE_JAR + + /* + * Write timestamp into outbuf. + * + * Complex because not all OSs have tm_gmtoff or + * the %z field in strftime() + */ + char tempbuf[ BUFFER_SIZE ]; + time_t now; + struct tm *tm_now; + time (&now); + tm_now = localtime (&now); + strftime (tempbuf, BUFFER_SIZE-6, "%b %d %H:%M:%S ", tm_now); + if (csp->config->jar) { - fprintf(csp->config->jar, "%s\t%s\n", csp->http->host, (s + v->len + 1)); + fprintf(csp->config->jar, "%s %s\t%s\n", tempbuf, csp->http->host, (s + v->len + 1)); } #endif /* def FEATURE_COOKIE_JAR */