diff mcabber/src/utils.c @ 378:2e6c7b1440d1

Improve debugging/logging * Tell the user when the tracelog file can't be open * Only include logprint.h when screen.h is not needed
author Mikael Berthe <mikael@lilotux.net>
date Tue, 26 Jul 2005 18:33:22 +0100
parents bd5638c21834
children f8f3c7493457
line wrap: on
line diff
--- a/mcabber/src/utils.c	Tue Jul 26 18:18:30 2005 +0100
+++ b/mcabber/src/utils.c	Tue Jul 26 18:33:22 2005 +0100
@@ -31,7 +31,7 @@
 #include <sys/stat.h>
 
 #include <config.h>
-#include "screen.h"
+#include "logprint.h"
 
 static int DebugEnabled;
 static char *FName;
@@ -63,7 +63,10 @@
   DebugEnabled = level;
 
   fp = fopen(FName, "a");
-  if (!fp) return;
+  if (!fp) {
+    fprintf(stderr, "ERROR: Cannot open tracelog file\n");
+    return;
+  }
   fprintf(fp, "New trace log started.\n"
 	  "----------------------\n");
   fchmod(fileno(fp), S_IRUSR|S_IWUSR);
@@ -77,7 +80,10 @@
   if (((DebugEnabled == 2) && (flag & (LPRINT_LOG|LPRINT_DEBUG))) ||
       ((DebugEnabled == 1) && (flag & LPRINT_LOG))) {
     FILE *fp = fopen(FName, "a+");
-    if (!fp) return;
+    if (!fp) {
+      scr_LogPrint(LPRINT_NORMAL, "ERROR: Cannot open tracelog file");
+      return;
+    }
     fputs(data, fp);
     fclose(fp);
   }