]> jfr.im git - irc/quakenet/newserv.git/blobdiff - core/error.c
CHANSERV: remove E type escapes
[irc/quakenet/newserv.git] / core / error.c
index edd986990bb5e7056f329c07c9c3fa5a3a403e1c..f7e554e3f8f97d356cd96460513c03d6d30408ad 100644 (file)
@@ -45,12 +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() {
   deregisterhook(HOOK_CORE_SIGUSR1, reopen_logfile);
-  fclose(logfile);
+  if (logfile)
+    fclose(logfile);
 }
 
 void Error(char *source, int severity, char *reason, ... ) {
@@ -75,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) {