From c926c05c6e826acb9a51be0fe5383b6276023a9d Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Mon, 19 Jun 2006 05:16:32 +0000 Subject: [PATCH] Always log E_LOG or higher to syslog, closing #137 --- src/err.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/err.c b/src/err.c index 659f8c2b..25ff813a 100644 --- a/src/err.c +++ b/src/err.c @@ -58,6 +58,7 @@ static FILE *err_file=NULL; /**< if logging to file, the handle of that file */ static pthread_mutex_t err_mutex=PTHREAD_MUTEX_INITIALIZER; /**< for serializing log messages */ static unsigned int err_debugmask=0xFFFFFFFF; /**< modules to debug, see \ref log_categories */ static int err_truncate = 0; +static int err_syslog_open = 0; /** text list of modules to match for setting debug mask */ static char *err_categorylist[] = { @@ -150,11 +151,12 @@ void err_log(int level, unsigned int cat, char *fmt, ...) if(!level) fprintf(stderr,"Aborting\n"); } - /* alwyas log fatals to syslog */ - if(!level) { - os_opensyslog(); // (app,LOG_PID,LOG_DAEMON); + /* always log fatals and level 1 to syslog */ + if(level <= 1) { + if(!err_syslog_open) + os_opensyslog(); + err_syslog_open=1; os_syslog(level,errbuf); - os_closesyslog(); } _err_unlock();