log: change internal logic to choose syslog over file logging.

Now that there is always a log file set, we just check for
syslog being set to TRUE and in that case use syslog logging,
file logging otherwiese.

Michael
This commit is contained in:
Michael Adam 2010-01-13 00:57:32 +01:00
parent fa0c4963e9
commit dc86ebaf28

View File

@ -252,18 +252,18 @@ int setup_logging (void)
/* Write to a user supplied log file if it's defined. This will /* Write to a user supplied log file if it's defined. This will
* override using the syslog even if syslog is defined. */ * override using the syslog even if syslog is defined. */
if (config.logf_name) { if (config.syslog) {
if (config.godaemon == TRUE)
openlog ("tinyproxy", LOG_PID, LOG_DAEMON);
else
openlog ("tinyproxy", LOG_PID, LOG_USER);
} else {
if (open_log_file (config.logf_name) < 0) { if (open_log_file (config.logf_name) < 0) {
fprintf (stderr, fprintf (stderr,
"%s: Could not create log file.\n", PACKAGE); "%s: Could not create log file.\n", PACKAGE);
goto done; goto done;
} }
config.syslog = FALSE; /* disable syslog */ config.syslog = FALSE; /* disable syslog */
} else if (config.syslog) {
if (config.godaemon == TRUE)
openlog ("tinyproxy", LOG_PID, LOG_DAEMON);
else
openlog ("tinyproxy", LOG_PID, LOG_USER);
} }
logging_initialized = TRUE; logging_initialized = TRUE;
@ -284,10 +284,10 @@ void shutdown_logging (void)
return; return;
} }
if (config.logf_name) { if (config.syslog) {
close_log_file ();
} else if (config.syslog) {
closelog (); closelog ();
} else {
close_log_file ();
} }
logging_initialized = FALSE; logging_initialized = FALSE;