Added the code for handling selective logging.

This commit is contained in:
Robert James Kaes 2001-06-02 03:09:27 +00:00
parent cce7ca652c
commit 2925b18412
2 changed files with 22 additions and 2 deletions

View File

@ -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

View File

@ -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