mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 18:25:07 -05:00
logging: allow reopening stderr
LOG_OpenFileLog(NULL) can be now used to reopen stderr.
This commit is contained in:
10
logging.c
10
logging.c
@@ -184,9 +184,13 @@ LOG_OpenFileLog(const char *log_file)
|
|||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fopen(log_file, "a");
|
if (log_file) {
|
||||||
if (!f)
|
f = fopen(log_file, "a");
|
||||||
LOG_FATAL("Could not open log file %s", log_file);
|
if (!f)
|
||||||
|
LOG_FATAL("Could not open log file %s", log_file);
|
||||||
|
} else {
|
||||||
|
f = stderr;
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable line buffering */
|
/* Enable line buffering */
|
||||||
setvbuf(f, NULL, _IOLBF, BUFSIZ);
|
setvbuf(f, NULL, _IOLBF, BUFSIZ);
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ extern void LOG_Message(LOG_Severity severity, const char *format, ...);
|
|||||||
*/
|
*/
|
||||||
extern void LOG_SetDebugLevel(int level);
|
extern void LOG_SetDebugLevel(int level);
|
||||||
|
|
||||||
/* Log messages to a file instead of stderr */
|
/* Log messages to a file instead of stderr, or stderr again if NULL */
|
||||||
extern void LOG_OpenFileLog(const char *log_file);
|
extern void LOG_OpenFileLog(const char *log_file);
|
||||||
|
|
||||||
/* Log messages to syslog instead of stderr */
|
/* Log messages to syslog instead of stderr */
|
||||||
|
|||||||
Reference in New Issue
Block a user