From b5cea714148a4954f141be22bee3d240a280a0e4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Dec 2019 16:29:21 +0000 Subject: [PATCH] log: Provide struct cfgfile_log This can be used as a logger during config reading. system_log is not available yet. Signed-off-by: Ian Jackson --- log.c | 6 ++++++ secnet.h | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/log.c b/log.c index e7d974d..3efd289 100644 --- a/log.c +++ b/log.c @@ -176,6 +176,12 @@ void cfgfatal(struct cloc loc, cstring_t facility, const char *message, ...) va_end(args); } +void cfgfile_log__vmsg(void *sst, int class, const char *message, va_list args) +{ + struct cfgfile_log *st=sst; + vcfgfatal_maybefile(0,st->loc,st->facility,message,args,"\n"); +} + void cfgfile_postreadcheck(struct cloc loc, FILE *f) { assert(loc.file); diff --git a/secnet.h b/secnet.h index c139796..26a0b55 100644 --- a/secnet.h +++ b/secnet.h @@ -640,6 +640,22 @@ FORMAT(printf,3,4); extern void vslilog_part(struct log_if *lf, int class, const char *message, va_list) FORMAT(printf,3,0); +void cfgfile_log__vmsg(void *sst, int class, const char *message, va_list); +struct cfgfile_log { + struct log_if log; + /* private fields */ + struct cloc loc; + const char *facility; +}; +static inline void cfgfile_log_init(struct cfgfile_log *cfl, + struct cloc loc, const char *facility) +{ + cfl->log.st=cfl; + cfl->log.vlogfn=cfgfile_log__vmsg; + cfl->loc=loc; + cfl->facility=facility; +} + /* SITE interface */ /* Pretty much a placeholder; allows starting and stopping of processing, -- 2.30.2