+see http://bugs.mutt.org/3263, this patch adds time/date to
+the entries in .muttdebug so it will be easier to correlate them
+to external events logged in tcpdump streams or logfiles
+
+--- a/init.c
++++ b/init.c
+@@ -2846,8 +2846,8 @@
+ {
+ t = time (0);
+ setbuf (debugfile, NULL); /* don't buffer the debugging output! */
+- fprintf (debugfile, "Mutt %s started at %s.\nDebugging at level %d.\n\n",
+- MUTT_VERSION, asctime (localtime (&t)), debuglevel);
++ dprint(1,(debugfile,"Mutt/%s (%s) debugging at level %d\n",
++ MUTT_VERSION, ReleaseDate, debuglevel));
+ }
+ }
+ #endif
+--- a/lib.c
++++ b/lib.c
+@@ -1007,6 +1007,24 @@
+ return sysexits_h[i].str;
+ }
+
++void mutt_debug (FILE *fp, const char *fmt, ...)
++{
++ va_list ap;
++ time_t now = time (NULL);
++ static char buf[23] = "";
++ static time_t last = 0;
++
++ if (now > last)
++ {
++ strftime (buf, sizeof (buf), "%Y-%m-%d %H:%M:%S", localtime (&now));
++ last = now;
++ }
++ fprintf (fp, "[%s] ", buf);
++ va_start (ap, fmt);
++ vfprintf (fp, fmt, ap);
++ va_end (ap);
++}
++
+ int mutt_atos (const char *str, short *dst)
+ {
+ int rc;
+--- a/lib.h
++++ b/lib.h
+@@ -126,7 +126,9 @@
+ MUTT_LIB_WHERE FILE *debugfile MUTT_LIB_INITVAL(0);
+ MUTT_LIB_WHERE int debuglevel MUTT_LIB_INITVAL(0);
+
+-# define dprint(N,X) do { if(debuglevel>=N && debugfile) fprintf X; } while (0)
++void mutt_debug (FILE *, const char *, ...);
++
++# define dprint(N,X) do { if(debuglevel>=N && debugfile) mutt_debug X; } while (0)
+
+ # else
+