summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2001-08-26 21:10:04 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2001-08-26 21:10:04 +0000
commite5819ebe1cf965a4a066c4f3b50c57c1a7ab8759 (patch)
tree269c5d54d7a2c364ce3d954f98e8d7e9b33dba95 /src
parent849345e88bd3bdb2bde1e531a3815308dc3e7bf0 (diff)
Added the Connect log level.
Diffstat (limited to 'src')
-rw-r--r--src/grammar.y7
-rw-r--r--src/log.c27
-rw-r--r--src/log.h12
-rw-r--r--src/scanner.l3
4 files changed, 40 insertions, 9 deletions
diff --git a/src/grammar.y b/src/grammar.y
index 42a8033..f3c07d1 100644
--- a/src/grammar.y
+++ b/src/grammar.y
@@ -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; }
;
diff --git a/src/log.c b/src/log.c
index f881b1c..1e3100c 100644
--- a/src/log.c
+++ b/src/log.c
@@ -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);
diff --git a/src/log.h b/src/log.h
index 03540e0..b9e2f0f 100644
--- a/src/log.h
+++ b/src/log.h
@@ -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");
diff --git a/src/scanner.l b/src/scanner.l
index 01c5843..5c4a975 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -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 */