From 3290032edf49242e6312097158c5a745a8dfedf9 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 8 May 2010 16:01:52 +0100 Subject: [PATCH] use libinn logging where applicable --- backends/innduct.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/backends/innduct.c b/backends/innduct.c index d9091d6..44a07c7 100644 --- a/backends/innduct.c +++ b/backends/innduct.c @@ -592,18 +592,32 @@ static void logv(int sysloglevel, const char *pfx, int errnoval, va_end(al); \ } -diewrap(syscrash, " critical", LOG_CRIT, errno, 16); -diewrap(crash, " critical", LOG_CRIT, -1, 16); +#define INNLOGWRAP_DECLARE(fn, pfx, sysloglevel) \ + static void duct_log_##fn(int errval, const char *fmt, va_list al, int l) { \ + logv(sysloglevel, pfx, errnoval ? errnoval : -1, fmt, al); \ + } +#define INNLOGWRAP_CALL(fn, pfx, sysloglevel) \ + fn##_set_handlers(1, duct_log_##fn); + + +static int innduct_fatal_cleanup(void) { return 12; } /* used for libinn die */ -diewrap(sysfatal, " fatal", LOG_ERR, errno, 12); -diewrap(fatal, " fatal", LOG_ERR, -1, 12); +/* We want to extend the set of logging functions from inn, and we + * want to prepend the site name to all our messages. */ -logwrap(syswarn, " warning", LOG_WARNING, errno); -logwrap(warn, " warning", LOG_WARNING, -1); +diewrap(syscrash, " critical", LOG_CRIT, errno, 16); +diewrap(crash, " critical", LOG_CRIT, -1, 16); -logwrap(notice, " notice", LOG_NOTICE, -1); -logwrap(info, " info", LOG_INFO, -1); -logwrap(debug, " debug", LOG_DEBUG, -1); +diewrap(sysfatal, " fatal", LOG_ERR, errno, 12); +diewrap(fatal, " fatal", LOG_ERR, -1, 12); + +#define INNLOGWRAPS \ + INNLOGWRAP(warn, " warning", LOG_WARNING, errno) \ + INNLOGWRAP(notice, " notice", LOG_NOTICE, -1) +INNLOGWRAPS(INNLOGWRAP_DECLARE) + +logwrap(info, " info", LOG_INFO, -1); +logwrap(debug, " debug", LOG_DEBUG, -1); /*========== utility functions etc. ==========*/ @@ -3717,6 +3731,11 @@ static int path_ends_slash(const char *specified) { } int main(int argc, char **argv) { + /* set up libinn logging */ + error_program_name= "innduct"; + message_fatal_cleanup= innduct_fatal_cleanup; + INNLOGWRAPS(INNLOGWRAP_CALL) + if (!argv[1]) { printusage(stderr); exit(8); @@ -3737,7 +3756,7 @@ int main(int argc, char **argv) { /* defaults */ int r= innconf_read(inndconffile); - if (!r) badusage("could not read inn.conf (more info on stderr)"); + if (!r) badusage("could not read inn.conf"); if (!remote_host) remote_host= sitename; -- 2.30.2