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. ==========*/
}
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);
/* 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;