X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/9e9df6d40f8ab71343e49b0720189d1691b214d3..056e1ea46d3a0707ca0bb46af4abd429e55c4196:/core/error.c diff --git a/core/error.c b/core/error.c index 6bc221cf..f7e554e3 100644 --- a/core/error.c +++ b/core/error.c @@ -40,14 +40,23 @@ void reopen_logfile(int hooknum, void *arg) { if (logfile) fclose(logfile); - logfile=fopen("log/newserv.log","a"); + logfile=fopen("logs/newserv.log","a"); } void init_logfile() { - logfile=fopen("log/newserv.log","a"); + logfile=fopen("logs/newserv.log","a"); + if (!logfile) { + fprintf(stderr,"Failed to open logfile...\n"); + } registerhook(HOOK_CORE_SIGUSR1, reopen_logfile); } +void fini_logfile() { + deregisterhook(HOOK_CORE_SIGUSR1, reopen_logfile); + if (logfile) + fclose(logfile); +} + void Error(char *source, int severity, char *reason, ... ) { char buf[512]; va_list va; @@ -70,8 +79,12 @@ void Error(char *source, int severity, char *reason, ... ) { tm=gmtime(&now); strftime(timebuf,100,"%Y-%m-%d %H:%M:%S",tm); fprintf(stderr,"[%s] %s(%s): %s\n",timebuf,sevtostring(severity),source,buf); - if (logfile) + fflush(stderr); + + if (logfile) { fprintf(logfile,"[%s] %s(%s): %s\n",timebuf,sevtostring(severity),source,buf); + fflush(logfile); + } } if (severity>=ERR_STOP) {