chiark / gitweb /
log: Set log level for early logging
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 May 2020 12:41:04 +0000 (13:41 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 24 May 2020 19:00:52 +0000 (20:00 +0100)
Unless ->level is set, logging is just a no-op.  We must set this
twice, because the system log is used to report command line parsing
errors, but the command line might increase the log level.

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 f937d2ec35d4500294d568d43da2e4258ed3512e..1ff2e5cd8c19df25c8da074df1b2e6733f6977b3 100644 (file)
--- a/log.c
+++ b/log.c
@@ -659,9 +659,14 @@ void log_from_fd(int fd, cstring_t prefix, struct log_if *log)
 }
 
 static struct logfile startup_log;
+void log_early_setlevel(void)
+{
+    startup_log.level=message_level;
+}
 void log_early_init(void)
 {
     logfile_file_init(&startup_log,stderr,"startup");
+    log_early_setlevel();
     system_log=&startup_log.ops;;
 }
 
index 2ebcddc1ae94491bbf5ad90edb1f12e3a84049dd..08505b0d5d81bd7cc94bbf9361f70f170babee21 100644 (file)
--- a/secnet.c
+++ b/secnet.c
@@ -500,6 +500,7 @@ int main(int argc, char **argv)
 
     enter_phase(PHASE_GETOPTS);
     parse_options(argc,argv);
+    log_early_setlevel();
 
     enter_phase(PHASE_READCONFIG);
     config=read_conffile(configfile);
index fd4b48f70cbeed0fd78d9ccafa7f201c8668292d..b54df229e290b4b0e734f8becf0ec4b69ae232a3 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -654,6 +654,7 @@ static inline void cfgfile_log_init(struct cfgfile_log *cfl,
 }
 
 void log_early_init(void);
+void log_early_setlevel(void);
 
 /* SITE interface */