more muttng -> madmutt
[apps/madmutt.git] / lib / debug.c
index ddf6284..6034ef9 100644 (file)
 #include <stdarg.h>
 #include <time.h>
 
+#include <lib-lib/str.h>
+#include <lib-lib/file.h>
 #include "debug.h"
 
 #include "mutt.h"
 #include "globals.h"
-#include "str.h"
 
 short DebugLevel = -1;
 FILE* DebugFile = NULL;
@@ -35,12 +36,13 @@ void debug_start (const char* basedir) {
   char buf[_POSIX_PATH_MAX];
   char buf2[_POSIX_PATH_MAX];
 
-  if (DebugLevel < 0 || !basedir || !*basedir)
+  if (DebugLevel < DEBUG_MIN_LEVEL || DebugLevel > DEBUG_MAX_LEVEL
+      || !basedir || !*basedir)
     return;
   /* rotate the old debug logs */
   for (i = 3; i >= 0; i--) {
-    snprintf (buf, sizeof (buf), "%s/.muttngdebug%d", NONULL (basedir), i);
-    snprintf (buf2, sizeof (buf2), "%s/.muttngdebug%d", NONULL (basedir), i + 1);
+    snprintf (buf, sizeof (buf), "%s/.madmuttdebug%d", NONULL (basedir), i);
+    snprintf (buf2, sizeof (buf2), "%s/.madmuttdebug%d", NONULL (basedir), i + 1);
     rename (buf, buf2);
   }
   if ((DebugFile = safe_fopen (buf, "w")) != NULL) {
@@ -53,7 +55,7 @@ void debug_start (const char* basedir) {
 }
 
 void _debug_print_intro (const char* file, int line, const char* function, int level) {
-  if (!DebugFile || DebugLevel < 0)
+  if (!DebugFile || DebugLevel < DEBUG_MIN_LEVEL || DebugLevel > DEBUG_MAX_LEVEL)
     return;
   fprintf (DebugFile, "[%d:%s:%d", level, NONULL(file), line);
   if (function && *function)