summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2001-06-02 03:09:27 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2001-06-02 03:09:27 +0000
commit2925b1841218ad90d0ecab84f133ffc1b86c2932 (patch)
treeadb199ff0a5d0dcc9f4107e05e9bda8ed9050536
parentcce7ca652ccc091c7d95450d71f84d28dd996513 (diff)
downloadtinyproxy-2925b1841218ad90d0ecab84f133ffc1b86c2932.tar.gz
tinyproxy-2925b1841218ad90d0ecab84f133ffc1b86c2932.zip
Added the code for handling selective logging.
-rw-r--r--src/log.c21
-rw-r--r--src/log.h3
2 files changed, 22 insertions, 2 deletions
diff --git a/src/log.c b/src/log.c
index 83569ad..cf0e207 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1,4 +1,4 @@
-/* $Id: log.c,v 1.4 2001-05-27 02:26:11 rjkaes Exp $
+/* $Id: log.c,v 1.5 2001-06-02 03:09:27 rjkaes Exp $
*
* Logs the various messages which tinyproxy produces to either a log file or
* the syslog daemon. Not much to it...
@@ -38,6 +38,19 @@ static char *syslog_level[] = {
#define STRING_LENGTH 800
/*
+ * Store the log level setting.
+ */
+static short int log_level = LOG_ERR;
+
+/*
+ * Set the log level for writing to the log file.
+ */
+void set_log_level(short int level)
+{
+ log_level = level;
+}
+
+/*
* This routine logs messages to either the log file or the syslog function.
*/
void log_message(short int level, char *fmt, ...)
@@ -51,6 +64,12 @@ void log_message(short int level, char *fmt, ...)
char str[STRING_LENGTH];
#endif
+ /*
+ * Figure out if we should write the message or not.
+ */
+ if (level > log_level)
+ return;
+
va_start(args, fmt);
#ifdef HAVE_SYSLOG_H
diff --git a/src/log.h b/src/log.h
index 2932e30..03540e0 100644
--- a/src/log.h
+++ b/src/log.h
@@ -1,4 +1,4 @@
-/* $Id: log.h,v 1.5 2001-06-02 02:07:34 rjkaes Exp $
+/* $Id: log.h,v 1.6 2001-06-02 03:09:27 rjkaes Exp $
*
* See 'log.c' for a detailed description.
*
@@ -90,5 +90,6 @@
#endif
extern void log_message(short int level, char *fmt, ...);
+extern void set_log_level(short int level);
#endif