GH-2641: Lazy-load syslog to avoid creating bro.log on Windows

This commit is contained in:
Tim Wojtulewicz 2022-12-09 15:39:53 -07:00 committed by Tim Wojtulewicz
parent 991652f479
commit a1e8af7745
2 changed files with 8 additions and 1 deletions

View file

@ -59,7 +59,7 @@ Reporter::Reporter(bool arg_abort_on_scripting_errors)
weird_sampling_duration = 0; weird_sampling_duration = 0;
weird_sampling_threshold = 0; weird_sampling_threshold = 0;
openlog("bro", 0, LOG_LOCAL5); syslog_open = false;
} }
Reporter::~Reporter() Reporter::~Reporter()
@ -265,6 +265,12 @@ void Reporter::Syslog(const char* fmt, ...)
if ( run_state::reading_traces ) if ( run_state::reading_traces )
return; return;
if ( ! syslog_open )
{
openlog("bro", 0, LOG_LOCAL5);
syslog_open = true;
}
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
vsyslog(LOG_NOTICE, fmt, ap); vsyslog(LOG_NOTICE, fmt, ap);

View file

@ -325,6 +325,7 @@ private:
int errors; int errors;
bool via_events; bool via_events;
bool syslog_open;
int in_error_handler; int in_error_handler;
bool info_to_stderr; bool info_to_stderr;
bool warnings_to_stderr; bool warnings_to_stderr;