chiark / gitweb /
log: Provide system_log from the very start
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Dec 2019 10:17:27 +0000 (10:17 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 Feb 2020 21:56:54 +0000 (21:56 +0000)
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 <ijackson@chiark.greenend.org.uk>
log.c
secnet.c
secnet.h

diff --git a/log.c b/log.c
index 6aced817eb0aa79cc868de3a1c60fdb16a6aa782..84f5a86abd610240bff0031a805213dc2aaa4589 100644 (file)
--- 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);
index c14a8354a16791764b004857692b5d6486f63152..69467de0172672dd4cb1070b7461b844ff07f290 100644 (file)
--- 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);
index 5b28c82ebec6584c8c6b4c35128a8e33757c7e03..5c351afb44a6e04d3e78308a67627e4e383268a0 100644 (file)
--- 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,