|
|
@ -10,7 +10,12 @@ |
|
|
|
#include <sys/syslog.h> |
|
|
|
#include <sys/syslog.h> |
|
|
|
|
|
|
|
|
|
|
|
static log_msgtype_t minlevel = log_info; |
|
|
|
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 FILE *logfile = NULL; |
|
|
|
|
|
|
|
|
|
|
|
static const char *loglevels[] = { |
|
|
|
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; } |
|
|
|
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() { |
|
|
|
void f2b_log_to_stderr() { |
|
|
|
if (logfile && logfile != stderr) |
|
|
|
if (logfile && logfile != stderr) |
|
|
|
fclose(logfile); |
|
|
|
fclose(logfile); |
|
|
|