]>
jfr.im git - irc/quakenet/newserv.git/blob - core/error.c
12 char *sevtostring(int severity
) {
30 return "terminal error";
33 return "unknown error";
37 void reopen_logfile(int hooknum
, void *arg
) {
41 logfile
=fopen("newserv.log","a");
45 logfile
=fopen("newserv.log","a");
46 registerhook(HOOK_CORE_SIGUSR1
, reopen_logfile
);
49 void Error(char *source
, int severity
, char *reason
, ... ) {
55 struct error_event evt
;
58 vsnprintf(buf
,512,reason
,va
);
61 evt
.severity
=severity
;
64 triggerhook(HOOK_CORE_ERROR
, &evt
);
66 if (severity
>ERR_DEBUG
) {
69 strftime(timebuf
,100,"%Y-%m-%d %H:%M:%S",tm
);
70 fprintf(stderr
,"[%s] %s(%s): %s\n",timebuf
,sevtostring(severity
),source
,buf
);
72 fprintf(logfile
,"[%s] %s(%s): %s\n",timebuf
,sevtostring(severity
),source
,buf
);
75 if (severity
>=ERR_STOP
) {
76 fprintf(stderr
,"Terminal error occured, exiting...\n");
77 triggerhook(HOOK_CORE_STOPERROR
, NULL
);