]> jfr.im git - irc/quakenet/newserv.git/blobdiff - core/error.c
CHANSERV: remove E type escapes
[irc/quakenet/newserv.git] / core / error.c
index ce34a9aebcae5fd3360a69e1547e586cf930b78c..f7e554e3f8f97d356cd96460513c03d6d30408ad 100644 (file)
@@ -45,13 +45,16 @@ void reopen_logfile(int hooknum, void *arg) {
 
 void init_logfile() {
   logfile=fopen("logs/newserv.log","a");
+  if (!logfile) {
+    fprintf(stderr,"Failed to open logfile...\n");
+  }
   registerhook(HOOK_CORE_SIGUSR1, reopen_logfile);
 }
 
 void fini_logfile() {
-  if (logfile) 
-    fclose(logfile);
   deregisterhook(HOOK_CORE_SIGUSR1, reopen_logfile);
+  if (logfile)
+    fclose(logfile);
 }
 
 void Error(char *source, int severity, char *reason, ... ) {
@@ -76,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) {