From 7ad083b0650b41902c383b20defb57b939be6587 Mon Sep 17 00:00:00 2001 From: Elizabeth Myers Date: Mon, 28 Mar 2016 19:06:31 -0500 Subject: [PATCH] logger: add idebug This only does something if debugging is enabled. --- include/logger.h | 1 + ircd/authd.c | 26 +++++++++++++------------- ircd/logger.c | 17 +++++++++++++++++ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/include/logger.h b/include/logger.h index 2d9d37fd..faa89270 100644 --- a/include/logger.h +++ b/include/logger.h @@ -55,6 +55,7 @@ extern void init_main_logfile(void); extern void open_logfiles(void); extern void close_logfiles(void); extern void ilog(ilogfile dest, const char *fmt, ...) AFP(2, 3); +extern void idebug(const char *fmt, ...) AFP(1, 2); extern void inotice(const char *fmt, ...) AFP(1, 2); extern void iwarn(const char *fmt, ...) AFP(1, 2); extern void ierror(const char *fmt, ...) AFP(1, 2); diff --git a/ircd/authd.c b/ircd/authd.c index 71949e3a..eae2a245 100644 --- a/ircd/authd.c +++ b/ircd/authd.c @@ -73,9 +73,8 @@ start_authd(void) ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix); if(access(fullpath, X_OK) == -1) { - ilog(L_MAIN, - "Unable to execute authd in %s or %s/bin", - ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath); + ierror("Unable to execute authd in %s or %s/bin", + ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath); sendto_realops_snomask(SNO_GENERAL, L_ALL, "Unable to execute authd in %s or %s/bin", ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath); @@ -100,7 +99,7 @@ start_authd(void) if(authd_helper == NULL) { - ilog(L_MAIN, "Unable to start authd helper: %s", strerror(errno)); + ierror("Unable to start authd helper: %s", strerror(errno)); sendto_realops_snomask(SNO_GENERAL, L_ALL, "Unable to start authd helper: %s", strerror(errno)); return 1; } @@ -211,7 +210,7 @@ parse_authd_reply(rb_helper * helper) case 'E': /* DNS Result */ if(parc != 5) { - ilog(L_MAIN, "authd sent a result with wrong number of arguments: got %d", parc); + iwarn("authd sent a result with wrong number of arguments: got %d", parc); restart_authd(); return; } @@ -220,7 +219,7 @@ parse_authd_reply(rb_helper * helper) case 'W': /* Oper warning */ if(parc != 3) { - ilog(L_MAIN, "authd sent a result with wrong number of arguments: got %d", parc); + iwarn("authd sent a result with wrong number of arguments: got %d", parc); restart_authd(); return; } @@ -229,18 +228,19 @@ parse_authd_reply(rb_helper * helper) { case 'D': /* Debug */ sendto_realops_snomask(SNO_DEBUG, L_ALL, "authd debug: %s", parv[3]); + idebug("authd: %s", parv[3]); break; case 'I': /* Info */ sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd info: %s", parv[3]); - inotice("authd info: %s", parv[3]); + inotice("authd: %s", parv[3]); break; case 'W': /* Warning */ sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd WARNING: %s", parv[3]); - iwarn("authd warning: %s", parv[3]); + iwarn("authd: %s", parv[3]); break; case 'C': /* Critical (error) */ sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd CRITICAL: %s", parv[3]); - ierror("authd critical: %s", parv[3]); + ierror("authd: %s", parv[3]); break; default: /* idk */ sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd sent us an unknown oper notice type (%s): %s", parv[2], parv[3]); @@ -255,7 +255,7 @@ parse_authd_reply(rb_helper * helper) case 'Z': /* End of stats reply */ if(parc < 3) { - ilog(L_MAIN, "authd sent a result with wrong number of arguments: got %d", parc); + iwarn("authd sent a result with wrong number of arguments: got %d", parc); restart_authd(); return; } @@ -267,7 +267,7 @@ parse_authd_reply(rb_helper * helper) /* parv[0] conveys status */ if(parc < 4) { - ilog(L_MAIN, "authd sent a result with wrong number of arguments: got %d", parc); + iwarn("authd sent a result with wrong number of arguments: got %d", parc); restart_authd(); return; } @@ -288,7 +288,7 @@ init_authd(void) { if(start_authd()) { - ilog(L_MAIN, "Unable to start authd helper: %s", strerror(errno)); + ierror("Unable to start authd helper: %s", strerror(errno)); exit(0); } } @@ -306,7 +306,7 @@ configure_authd(void) static void restart_authd_cb(rb_helper * helper) { - ilog(L_MAIN, "authd: restart_authd_cb called, authd died?"); + iwarn("authd: restart_authd_cb called, authd died?"); sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd: restart_authd_cb called, authd died?"); if(helper != NULL) { diff --git a/ircd/logger.c b/ircd/logger.c index c4de984c..3b81acd7 100644 --- a/ircd/logger.c +++ b/ircd/logger.c @@ -200,6 +200,23 @@ _iprint(const char *domain, const char *buf) fprintf(stderr, "%8s: %s\n", domain, buf); } +void +idebug(const char *format, ...) +{ +#ifndef NDEBUG + char buf[BUFSIZE]; + va_list args; + + va_start(args, format); + vsnprintf(buf, sizeof(buf), format, args); + va_end(args); + + _iprint("debug", buf); + + ilog(L_MAIN, "%s", buf); +#endif +} + void inotice(const char *format, ...) {