don't touch bip.log if log = false
This commit is contained in:
parent
ed8f084dae
commit
5ad0a47e68
15
src/bip.c
15
src/bip.c
@ -168,17 +168,22 @@ static pid_t daemonize(void)
|
||||
}
|
||||
if (setsid() < 0)
|
||||
fatal("setsid() failed");
|
||||
snprintf(buf, 4095, "%s/bip.log", conf_log_root);
|
||||
FILE *f = fopen(buf, "a");
|
||||
if (!f)
|
||||
fatal("Can't open %s: %s", buf, strerror(errno));
|
||||
|
||||
if (conf_log) {
|
||||
snprintf(buf, 4095, "%s/bip.log", conf_log_root);
|
||||
FILE *f = fopen(buf, "a");
|
||||
if (!f)
|
||||
fatal("Can't open %s: %s", buf, strerror(errno));
|
||||
conf_global_log_file = f;
|
||||
} else {
|
||||
conf_global_log_file = stderr;
|
||||
}
|
||||
|
||||
close(0);
|
||||
close(1);
|
||||
close(2);
|
||||
/* This better be the very last action since fatal makes use of
|
||||
* conf_global_log_file */
|
||||
conf_global_log_file = f;
|
||||
return getpid();
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
extern int conf_log_level;
|
||||
extern int conf_log;
|
||||
extern int errno;
|
||||
|
||||
/*
|
||||
@ -117,6 +118,10 @@ void _mylog(int level, char *fmt, va_list ap)
|
||||
void mylog(int level, char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (!conf_log)
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
_mylog(level, fmt, ap);
|
||||
va_end(ap);
|
||||
|
Loading…
Reference in New Issue
Block a user