From 328292c7927b477d9a732f21732edf5885d67793 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 8 Dec 2019 10:17:27 +0000 Subject: [PATCH] log: Provide system_log from the very start It is just too inconvenient not to have this while reading the config. Set up a default system_log which logs to stderr. When setup_log is called, system_log will be overwritten and this struct is no longer used. Signed-off-by: Ian Jackson --- log.c | 10 ++++++++++ secnet.c | 1 + secnet.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/log.c b/log.c index 6aced81..84f5a86 100644 --- a/log.c +++ b/log.c @@ -663,6 +663,16 @@ void log_from_fd(int fd, cstring_t prefix, struct log_if *log) prefix); } +static struct logfile startup_log; +void log_early_init(void) +{ + logfile_file_init(&startup_log,stderr,"startup"); + system_log=&startup_log.ops;; +} + +/* for the benefit of main, really */ +void logfile_init_file(struct logfile *st, FILE *f); + void log_module(dict_t *dict) { setlinebuf(stderr); diff --git a/secnet.c b/secnet.c index c14a835..69467de 100644 --- a/secnet.c +++ b/secnet.c @@ -493,6 +493,7 @@ int main(int argc, char **argv) { dict_t *config; + log_early_init(); phase_hooks_init(); enter_phase(PHASE_GETOPTS); diff --git a/secnet.h b/secnet.h index 5b28c82..5c351af 100644 --- a/secnet.h +++ b/secnet.h @@ -657,6 +657,8 @@ static inline void cfgfile_log_init(struct cfgfile_log *cfl, cfl->facility=facility; } +void log_early_init(void); + /* SITE interface */ /* Pretty much a placeholder; allows starting and stopping of processing, -- 2.30.2