diff -ru -I Id: -x CVS -N dbmail/debug.c dbmail.working/debug.c
--- dbmail/debug.c	2002-11-13 11:21:07.000000000 +1300
+++ dbmail.working/debug.c	2002-11-08 13:26:44.000000000 +1300
@@ -22,21 +22,34 @@
 
 #define err_out_stream stderr
 #define EXIT_CODE 75
+#define MAX_FORMATSTRING 1024
 
 /* the debug variables */
-int TRACE_TO_SYSLOG = 1; /* default: yes */
-int TRACE_VERBOSE = 0;   /* default: no */
-int TRACE_LEVEL = 5;     /* default: verbose operations */
+int _TRACE_TO_SYSLOG = 1; /* default: yes */
+int _TRACE_VERBOSE = 0;   /* default: no */
+int _TRACE_LEVEL = 2;     /* default: verbose operations */
+
+const char *TRACE_LEVELS[] = 
+{
+  "FATAL",
+  "STOP",
+  "MESG",
+  "ERROR",
+  "WARN",
+  "INFO",
+  "DEBUG" 
+};
 
+char new_formatstring[MAX_FORMATSTRING];
 
 /*
  * configure the debug settings
  */
 void configure_debug(int level, int trace_syslog, int trace_verbose)
 {
-  TRACE_LEVEL = level;
-  TRACE_TO_SYSLOG = trace_syslog;
-  TRACE_VERBOSE = trace_verbose;
+  _TRACE_LEVEL = level;
+  _TRACE_TO_SYSLOG = trace_syslog;
+  _TRACE_VERBOSE = trace_verbose;
 }
 
 void func_memtst (const char *filename,int line,int tst)
@@ -48,47 +61,42 @@
 
 void trace (int level, char *formatstring, ...)
 {
-  va_list argp;
-  
-  va_start(argp, formatstring);
+   va_list argp;
+   va_start(argp, formatstring);
 
-  if (level <= TRACE_LEVEL)
-    {
-      if (TRACE_VERBOSE)
+   if (level <= _TRACE_LEVEL)
+   {
+      snprintf (new_formatstring, MAX_FORMATSTRING, "[%s] %s", TRACE_LEVELS[level+1], formatstring);
+
+      if (_TRACE_VERBOSE)
       { 
-	vfprintf (err_out_stream, formatstring, argp);
-        if (formatstring[strlen(formatstring)]!='\n')
-	  fprintf (err_out_stream,"\n");
+         vfprintf (err_out_stream, new_formatstring, argp);
+         if (new_formatstring[strlen(new_formatstring)]!='\n')
+            fprintf (err_out_stream,"\n");
       }
-      if (TRACE_TO_SYSLOG)
-	{
-	  if (formatstring[strlen(formatstring)]=='\n')
-            formatstring[strlen(formatstring)]='\0';
-	  if (level <= TRACE_WARNING) 
-	    {
-	      /* set LOG_ALERT at warnings */
-	      vsyslog (LOG_ALERT, formatstring, argp);
-	    }
-	  else 
-	    vsyslog (LOG_NOTICE, formatstring, argp);
-	}
-      va_end(argp);
-    }
-  else
-    if (level == TRACE_MESSAGE)
+      if (_TRACE_TO_SYSLOG)
       {
-	vsyslog (LOG_NOTICE, formatstring, argp);
-	va_end(argp);
+         if (new_formatstring[strlen(new_formatstring)]=='\n')
+            new_formatstring[strlen(new_formatstring)]='\0';
+         if (level <= TRACE_WARNING) 
+         {
+            /* set LOG_ALERT at warnings */
+            vsyslog (LOG_ALERT, new_formatstring, argp);
+         }
+         else 
+            vsyslog (LOG_NOTICE, new_formatstring, argp);
       }
+      va_end(argp);
+   }
+
 
-  /* very big fatal error 
+   /* very big fatal error 
    * bailout */
-	
-  if (level==TRACE_FATAL)
-    exit(EXIT_CODE);
+   if (level==TRACE_FATAL)
+      exit(EXIT_CODE);
 
-  if (level==TRACE_STOP)
-    exit(EXIT_CODE);
+   if (level==TRACE_STOP)
+      exit(EXIT_CODE);
 }
 
 void* __debug_malloc(unsigned long size, const char *fname, int linenr)
diff -ru -I Id: -x CVS -N dbmail/debug.h dbmail.working/debug.h
--- dbmail/debug.h	2002-11-13 11:21:07.000000000 +1300
+++ dbmail.working/debug.h	2002-11-06 17:33:03.000000000 +1300
@@ -10,10 +10,13 @@
 #ifndef  _DEBUG_H
 #define  _DEBUG_H
 
-extern int TRACE_TO_SYSLOG;
-extern int TRACE_VERBOSE;
-
-extern int TRACE_LEVEL;     /* 5: maximum debugging */
+/* Changed name of external variables, since they
+   only are used in debug.c. I use the names without
+   '_' for command line arguments, in config.h and
+   dbmail.config. / Klas Handel */
+extern int _TRACE_TO_SYSLOG;
+extern int _TRACE_VERBOSE;
+extern int _TRACE_LEVEL;     /* 5: maximum debugging */
                             /* 2: normal operations */
 
 #define TRACE_FATAL -1
