From 2925b1841218ad90d0ecab84f133ffc1b86c2932 Mon Sep 17 00:00:00 2001 From: Robert James Kaes Date: Sat, 2 Jun 2001 03:09:27 +0000 Subject: Added the code for handling selective logging. --- src/log.c | 21 ++++++++++++++++++++- src/log.h | 3 ++- 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... @@ -37,6 +37,19 @@ static char *syslog_level[] = { #define TIME_LENGTH 16 #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. */ @@ -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 -- cgit v1.2.3