projects
/
privoxy.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add FEATURE_EXTENDED_STATISTICS to gather filter statistics
[privoxy.git]
/
errlog.c
diff --git
a/errlog.c
b/errlog.c
index
05b7dd8
..
7cc4e20
100644
(file)
--- a/
errlog.c
+++ b/
errlog.c
@@
-1,4
+1,3
@@
-const char errlog_rcs[] = "$Id: errlog.c,v 1.126 2016/02/26 12:29:38 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/errlog.c,v $
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/errlog.c,v $
@@
-7,7
+6,7
@@
const char errlog_rcs[] = "$Id: errlog.c,v 1.126 2016/02/26 12:29:38 fabiankeil
* printf-like fashion.
*
* Copyright : Written by and Copyright (C) 2001-2014 the
* printf-like fashion.
*
* Copyright : Written by and Copyright (C) 2001-2014 the
- * Privoxy team. http://www.privoxy.org/
+ * Privoxy team. http
s
://www.privoxy.org/
*
* Based on the Internet Junkbuster originally written
* by and Copyright (C) 1997 Anonymous Coders and
*
* Based on the Internet Junkbuster originally written
* by and Copyright (C) 1997 Anonymous Coders and
@@
-79,9
+78,6
@@
const char errlog_rcs[] = "$Id: errlog.c,v 1.126 2016/02/26 12:29:38 fabiankeil
#include "jbsockets.h"
#endif
#include "jbsockets.h"
#endif
-const char errlog_h_rcs[] = ERRLOG_H_VERSION;
-
-
/*
* LOG_LEVEL_FATAL cannot be turned off. (There are
* some exceptional situations where we need to get a
/*
* LOG_LEVEL_FATAL cannot be turned off. (There are
* some exceptional situations where we need to get a
@@
-537,21
+533,12
@@
static inline size_t get_clf_timestamp(char *buffer, size_t buffer_size)
int tz_length = 0;
time (&now);
int tz_length = 0;
time (&now);
-#ifdef HAVE_GMTIME_R
- gmt = *gmtime_r(&now, &gmt);
-#elif defined(MUTEX_LOCKS_AVAILABLE)
- privoxy_mutex_lock(&gmtime_mutex);
- gmt = *gmtime(&now);
- privoxy_mutex_unlock(&gmtime_mutex);
-#else
- gmt = *gmtime(&now);
-#endif
+ gmt = *privoxy_gmtime_r(&now, &gmt);
#ifdef HAVE_LOCALTIME_R
tm_now = localtime_r(&now, &dummy);
#elif defined(MUTEX_LOCKS_AVAILABLE)
privoxy_mutex_lock(&localtime_mutex);
tm_now = localtime(&now);
#ifdef HAVE_LOCALTIME_R
tm_now = localtime_r(&now, &dummy);
#elif defined(MUTEX_LOCKS_AVAILABLE)
privoxy_mutex_lock(&localtime_mutex);
tm_now = localtime(&now);
- privoxy_mutex_unlock(&localtime_mutex);
#else
tm_now = localtime(&now);
#endif
#else
tm_now = localtime(&now);
#endif
@@
-560,6
+547,9
@@
static inline size_t get_clf_timestamp(char *buffer, size_t buffer_size)
mins = hrs * 60 + tm_now->tm_min - gmt.tm_min;
length = strftime(buffer, buffer_size, "%d/%b/%Y:%H:%M:%S ", tm_now);
mins = hrs * 60 + tm_now->tm_min - gmt.tm_min;
length = strftime(buffer, buffer_size, "%d/%b/%Y:%H:%M:%S ", tm_now);
+#if !defined(HAVE_LOCALTIME_R) && defined(MUTEX_LOCKS_AVAILABLE)
+ privoxy_mutex_unlock(&localtime_mutex);
+#endif
if (length > (size_t)0)
{
if (length > (size_t)0)
{
@@
-605,7
+595,7
@@
static inline const char *get_log_level_string(int loglevel)
case LOG_LEVEL_FATAL:
log_level_string = "Fatal error";
break;
case LOG_LEVEL_FATAL:
log_level_string = "Fatal error";
break;
- case LOG_LEVEL_
GPC
:
+ case LOG_LEVEL_
REQUEST
:
log_level_string = "Request";
break;
case LOG_LEVEL_CONNECT:
log_level_string = "Request";
break;
case LOG_LEVEL_CONNECT:
@@
-674,19
+664,13
@@
static inline const char *get_log_level_string(int loglevel)
void log_error(int loglevel, const char *fmt, ...)
{
va_list ap;
void log_error(int loglevel, const char *fmt, ...)
{
va_list ap;
- char *outbuf = NULL;
- static char *outbuf_save = NULL;
+ char outbuf[LOG_BUFFER_SIZE+1];
char tempbuf[LOG_BUFFER_SIZE];
size_t length = 0;
const char * src = fmt;
long thread_id;
char timestamp[30];
char tempbuf[LOG_BUFFER_SIZE];
size_t length = 0;
const char * src = fmt;
long thread_id;
char timestamp[30];
- /*
- * XXX: Make this a config option,
- * why else do we allocate instead of using
- * an array?
- */
- size_t log_buffer_size = LOG_BUFFER_SIZE;
+ const size_t log_buffer_size = LOG_BUFFER_SIZE;
#if defined(_WIN32) && !defined(_WIN_CONSOLE)
/*
#if defined(_WIN32) && !defined(_WIN_CONSOLE)
/*
@@
-694,7
+678,7
@@
void log_error(int loglevel, const char *fmt, ...)
* the taskbar icon animate. (There is an option to disable
* this but checking that is handled inside LogShowActivity()).
*/
* the taskbar icon animate. (There is an option to disable
* this but checking that is handled inside LogShowActivity()).
*/
- if ((loglevel == LOG_LEVEL_
GPC
) || (loglevel == LOG_LEVEL_CRUNCH))
+ if ((loglevel == LOG_LEVEL_
REQUEST
) || (loglevel == LOG_LEVEL_CRUNCH))
{
LogShowActivity();
}
{
LogShowActivity();
}
@@
-728,20
+712,11
@@
void log_error(int loglevel, const char *fmt, ...)
thread_id = get_thread_id();
get_log_timestamp(timestamp, sizeof(timestamp));
thread_id = get_thread_id();
get_log_timestamp(timestamp, sizeof(timestamp));
- /* protect the whole function because of the static buffer (outbuf) */
- lock_logfile();
-
- if (NULL == outbuf_save)
- {
- outbuf_save = zalloc_or_die(log_buffer_size + 1); /* +1 for paranoia */
- }
- outbuf = outbuf_save;
-
/*
* Memsetting the whole buffer to zero (in theory)
* makes things easier later on.
*/
/*
* Memsetting the whole buffer to zero (in theory)
* makes things easier later on.
*/
- memset(outbuf, 0,
log_buffer_size
);
+ memset(outbuf, 0,
sizeof(outbuf)
);
/* Add prefix for everything but Common Log Format messages */
if (loglevel != LOG_LEVEL_CLF)
/* Add prefix for everything but Common Log Format messages */
if (loglevel != LOG_LEVEL_CLF)
@@
-818,7
+793,7
@@
void log_error(int loglevel, const char *fmt, ...)
break;
case 'c':
/*
break;
case 'c':
/*
- * Note that char param
a
ters are converted to int, so we need to
+ * Note that char param
e
ters are converted to int, so we need to
* pass "int" to va_arg. (See K&R, 2nd ed, section A7.3.2, page 202)
*/
tempbuf[0] = (char) va_arg(ap, int);
* pass "int" to va_arg. (See K&R, 2nd ed, section A7.3.2, page 202)
*/
tempbuf[0] = (char) va_arg(ap, int);
@@
-955,19
+930,21
@@
void log_error(int loglevel, const char *fmt, ...)
assert(NULL != logfp);
#endif
assert(NULL != logfp);
#endif
+ lock_logfile();
+
if (loglevel == LOG_LEVEL_FATAL)
{
if (loglevel == LOG_LEVEL_FATAL)
{
- fatal_error(outbuf
_save
);
+ fatal_error(outbuf);
/* Never get here */
}
if (logfp != NULL)
{
/* Never get here */
}
if (logfp != NULL)
{
- fputs(outbuf
_save
, logfp);
+ fputs(outbuf, logfp);
}
#if defined(_WIN32) && !defined(_WIN_CONSOLE)
/* Write to display */
}
#if defined(_WIN32) && !defined(_WIN_CONSOLE)
/* Write to display */
- LogPutString(outbuf
_save
);
+ LogPutString(outbuf);
#endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */
unlock_logfile();
#endif /* defined(_WIN32) && !defined(_WIN_CONSOLE) */
unlock_logfile();
@@
-981,17
+958,13
@@
void log_error(int loglevel, const char *fmt, ...)
*
* Description : Translates JB_ERR_FOO codes into strings.
*
*
* Description : Translates JB_ERR_FOO codes into strings.
*
- * XXX: the type of error codes is jb_err
- * but the typedef'inition is currently not
- * visible to all files that include errlog.h.
- *
* Parameters :
* 1 : jb_error = a valid jb_err code
*
* Returns : A string with the jb_err translation
*
*********************************************************************/
* Parameters :
* 1 : jb_error = a valid jb_err code
*
* Returns : A string with the jb_err translation
*
*********************************************************************/
-const char *jb_err_to_string(
int
jb_error)
+const char *jb_err_to_string(
jb_err
jb_error)
{
switch (jb_error)
{
{
switch (jb_error)
{