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