Added the Connect log level.

This commit is contained in:
Robert James Kaes 2001-08-26 21:10:04 +00:00
parent 849345e88b
commit e5819ebe1c
4 changed files with 40 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $Id: grammar.y,v 1.3 2001-06-02 03:10:09 rjkaes Exp $
/* $Id: grammar.y,v 1.4 2001-08-26 21:08:36 rjkaes Exp $
*
* This is the grammar for tinyproxy's configuration file. It needs to be
* in sync with scanner.l. If you know more about yacc and lex than I do
@ -52,7 +52,7 @@ int yylex(void);
/* settings for loglevel */
%token KW_LOGLEVEL
%token KW_LOG_CRITICAL KW_LOG_ERROR KW_LOG_WARNING KW_LOG_NOTICE KW_LOG_INFO
%token KW_LOG_CRITICAL KW_LOG_ERROR KW_LOG_WARNING KW_LOG_NOTICE KW_LOG_CONNECT KW_LOG_INFO
%token <cptr> IDENTIFIER
%token <num> NUMBER
@ -105,7 +105,7 @@ statement
| KW_PIDFILE string { config.pidpath = $2; }
| KW_USER string { config.username = $2; }
| KW_GROUP string { config.group = $2; }
| KW_ANONYMOUS string { anon_insert($2); }
| KW_ANONYMOUS string { anonymous_insert($2); }
| KW_FILTER string
{
#ifdef FILTER_ENABLE
@ -135,6 +135,7 @@ loglevels
| KW_LOG_ERROR { $$ = LOG_ERR; }
| KW_LOG_WARNING { $$ = LOG_WARNING; }
| KW_LOG_NOTICE { $$ = LOG_NOTICE; }
| KW_LOG_CONNECT { $$ = LOG_CONN; }
| KW_LOG_INFO { $$ = LOG_INFO; }
;

View File

@ -1,4 +1,4 @@
/* $Id: log.c,v 1.8 2001-06-06 19:32:51 rjkaes Exp $
/* $Id: log.c,v 1.9 2001-08-26 21:10:04 rjkaes Exp $
*
* Logs the various messages which tinyproxy produces to either a log file or
* the syslog daemon. Not much to it...
@ -31,7 +31,8 @@ static char *syslog_level[] = {
"WARNING",
"NOTICE",
"INFO",
"DEBUG"
"DEBUG",
"CONNECT"
};
#define TIME_LENGTH 16
@ -47,7 +48,15 @@ static short int log_level = LOG_ERR;
*/
void set_log_level(short int level)
{
#ifndef NDEBUG
/*
* If we're running with debugging enabled, then set the log level
* to DEBUG regardless of what's in the configuration file.
*/
log_level = LOG_DEBUG;
#else
log_level = level;
#endif
}
/*
@ -67,8 +76,18 @@ void log_message(short int level, char *fmt, ...)
/*
* Figure out if we should write the message or not.
*/
if (level > log_level)
return;
if (log_level != LOG_CONN) {
if (level > log_level && level != LOG_CONN)
return;
} else {
if (level == LOG_INFO)
return;
}
#ifdef HAVE_SYSLOG_H
if (config.syslog && level == LOG_CONN)
level = LOG_INFO;
#endif
va_start(args, fmt);

View File

@ -1,4 +1,4 @@
/* $Id: log.h,v 1.6 2001-06-02 03:09:27 rjkaes Exp $
/* $Id: log.h,v 1.7 2001-08-26 21:10:04 rjkaes Exp $
*
* See 'log.c' for a detailed description.
*
@ -29,6 +29,9 @@
* can see them below and I'll describe what each level should be for.
* Hopefully tinyproxy will remain consistent with these levels.
* -- rjkaes
* Sorry but I had to destroy the hope ;-) There was a need to log
* connections without the INFO stuff and not to have them as NOTICE.
* -- hgb
*
* Level Description
* ----- -----------
@ -56,6 +59,11 @@
* now it is used for actions like creating/destroying threads,
* unauthorized access, signal handling, etc.
*
* LOG_CONN This additional level is for logging connections only, so
* it is easy to control only the requests in the logfile.
* If we log through syslog, this is set to LOG_INFO.
* -- hgb
*
* LOG_INFO Everything else ends up here. Logging for incoming
* connections, denying due to filtering rules, unable to
* connect to remote server, etc.
@ -76,6 +84,8 @@
# define LOG_DEBUG 7
#endif
#define LOG_CONN 8 /* extra to log connections without the INFO stuff */
/*
* Use this for debugging. The format is specific:
* DEBUG1("There was a major problem");

View File

@ -1,4 +1,4 @@
/* $Id: scanner.l,v 1.3 2001-06-02 03:10:09 rjkaes Exp $
/* $Id: scanner.l,v 1.4 2001-08-26 21:08:36 rjkaes Exp $
*
* This builds the scanner for the tinyproxy configuration file. This
* file needs to stay in sync with grammar.y. If someone knows lex and yacc
@ -56,6 +56,7 @@ static struct keyword keywords[] = {
{ "error", KW_LOG_ERROR },
{ "warning", KW_LOG_WARNING },
{ "notice", KW_LOG_NOTICE },
{ "connect", KW_LOG_CONNECT },
{ "info", KW_LOG_INFO },
/* on/off switches */