logger: add idebug

This only does something if debugging is enabled.
This commit is contained in:
Elizabeth Myers 2016-03-28 19:06:31 -05:00
parent bae7e637de
commit 7ad083b065
3 changed files with 31 additions and 13 deletions

View file

@ -55,6 +55,7 @@ extern void init_main_logfile(void);
extern void open_logfiles(void); extern void open_logfiles(void);
extern void close_logfiles(void); extern void close_logfiles(void);
extern void ilog(ilogfile dest, const char *fmt, ...) AFP(2, 3); 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 inotice(const char *fmt, ...) AFP(1, 2);
extern void iwarn(const char *fmt, ...) AFP(1, 2); extern void iwarn(const char *fmt, ...) AFP(1, 2);
extern void ierror(const char *fmt, ...) AFP(1, 2); extern void ierror(const char *fmt, ...) AFP(1, 2);

View file

@ -73,8 +73,7 @@ start_authd(void)
ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix); ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix);
if(access(fullpath, X_OK) == -1) if(access(fullpath, X_OK) == -1)
{ {
ilog(L_MAIN, ierror("Unable to execute authd in %s or %s/bin",
"Unable to execute authd in %s or %s/bin",
ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath); ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
sendto_realops_snomask(SNO_GENERAL, L_ALL, sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Unable to execute authd in %s or %s/bin", "Unable to execute authd in %s or %s/bin",
@ -100,7 +99,7 @@ start_authd(void)
if(authd_helper == NULL) 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)); sendto_realops_snomask(SNO_GENERAL, L_ALL, "Unable to start authd helper: %s", strerror(errno));
return 1; return 1;
} }
@ -211,7 +210,7 @@ parse_authd_reply(rb_helper * helper)
case 'E': /* DNS Result */ case 'E': /* DNS Result */
if(parc != 5) 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(); restart_authd();
return; return;
} }
@ -220,7 +219,7 @@ parse_authd_reply(rb_helper * helper)
case 'W': /* Oper warning */ case 'W': /* Oper warning */
if(parc != 3) 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(); restart_authd();
return; return;
} }
@ -229,18 +228,19 @@ parse_authd_reply(rb_helper * helper)
{ {
case 'D': /* Debug */ case 'D': /* Debug */
sendto_realops_snomask(SNO_DEBUG, L_ALL, "authd debug: %s", parv[3]); sendto_realops_snomask(SNO_DEBUG, L_ALL, "authd debug: %s", parv[3]);
idebug("authd: %s", parv[3]);
break; break;
case 'I': /* Info */ case 'I': /* Info */
sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd info: %s", parv[3]); sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd info: %s", parv[3]);
inotice("authd info: %s", parv[3]); inotice("authd: %s", parv[3]);
break; break;
case 'W': /* Warning */ case 'W': /* Warning */
sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd WARNING: %s", parv[3]); sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd WARNING: %s", parv[3]);
iwarn("authd warning: %s", parv[3]); iwarn("authd: %s", parv[3]);
break; break;
case 'C': /* Critical (error) */ case 'C': /* Critical (error) */
sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd CRITICAL: %s", parv[3]); sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd CRITICAL: %s", parv[3]);
ierror("authd critical: %s", parv[3]); ierror("authd: %s", parv[3]);
break; break;
default: /* idk */ default: /* idk */
sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd sent us an unknown oper notice type (%s): %s", parv[2], parv[3]); 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 */ case 'Z': /* End of stats reply */
if(parc < 3) 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(); restart_authd();
return; return;
} }
@ -267,7 +267,7 @@ parse_authd_reply(rb_helper * helper)
/* parv[0] conveys status */ /* parv[0] conveys status */
if(parc < 4) 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(); restart_authd();
return; return;
} }
@ -288,7 +288,7 @@ init_authd(void)
{ {
if(start_authd()) 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); exit(0);
} }
} }
@ -306,7 +306,7 @@ configure_authd(void)
static void static void
restart_authd_cb(rb_helper * helper) 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?"); sendto_realops_snomask(SNO_GENERAL, L_ALL, "authd: restart_authd_cb called, authd died?");
if(helper != NULL) if(helper != NULL)
{ {

View file

@ -200,6 +200,23 @@ _iprint(const char *domain, const char *buf)
fprintf(stderr, "%8s: %s\n", domain, 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 void
inotice(const char *format, ...) inotice(const char *format, ...)
{ {