diff --git a/configs/f2b.conf.in b/configs/f2b.conf.in index d3fd76e..78d23e7 100644 --- a/configs/f2b.conf.in +++ b/configs/f2b.conf.in @@ -2,6 +2,7 @@ includes = ${CMAKE_INSTALL_FULL_SYSCONFDIR}/f2b/conf-enabled pidfile = /var/run/f2b.pid statedir = ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/f2b +; valid destinations: stdout, stderr, syslog, file (logfile option should be set) logdest = syslog loglevel = info logfile = /var/log/f2b.log diff --git a/src/log.c b/src/log.c index 68660f0..eb2c787 100644 --- a/src/log.c +++ b/src/log.c @@ -10,7 +10,12 @@ #include static log_msgtype_t minlevel = log_info; -static enum { log_stderr = 0, log_file = 1, log_syslog = 2 } dest = log_stderr; +static enum { + log_stderr = 0, + log_stdout = 1, + log_file = 2, + log_syslog = 3 +} dest = log_stderr; static FILE *logfile = NULL; static const char *loglevels[] = { @@ -79,6 +84,13 @@ void f2b_log_set_level(const char *level) { if (strcmp(level, "fatal") == 0) { minlevel = log_fatal; return; } } +void f2b_log_to_stdout() { + if (logfile && logfile != stdout) + fclose(logfile); + dest = log_stdout; + logfile = stdout; +} + void f2b_log_to_stderr() { if (logfile && logfile != stderr) fclose(logfile); diff --git a/src/log.h b/src/log.h index e97ae9a..33da7ae 100644 --- a/src/log.h +++ b/src/log.h @@ -52,6 +52,8 @@ void f2b_log_set_level(const char *level); * @param path Path for logfile */ void f2b_log_to_file (const char *path); +/** @brief Use logging to stdout */ +void f2b_log_to_stdout(); /** @brief Use logging to stderr */ void f2b_log_to_stderr(); /** @brief Use logging to syslog */