[git] GpgOL - branch, master, updated. gpgol-2.3.0-33-g635ff92

by Andre Heinecke cvs at cvs.gnupg.org
Mon Sep 24 10:01:48 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, master has been updated
       via  635ff920f8c22087d27b62f8a597fe36e9925ff8 (commit)
       via  9e42f7008b4d089546070cc4de4a461fb96e8e97 (commit)
      from  4bc8476bd340a1c43052b4a3285a1dde582c0296 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 635ff920f8c22087d27b62f8a597fe36e9925ff8
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 24 09:38:29 2018 +0200

    Start simplification of log categories
    
    * src/debug.cpp, src/debug.h: New. Place for log functionality.
    * src/common.cpp, src/common_indep.c, src/common_indep.h: Move out
    debugging functions.
    * src/keycache.cpp, src/mail.cpp, src/main.c,
    src/mimedataprovider.cpp, src/oomhelp.cpp,
    src/parsecontroller.cpp: Rename log_mime_parser to log data.

diff --git a/src/Makefile.am b/src/Makefile.am
index 9abce23..47643fa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,6 +35,7 @@ gpgol_SOURCES = \
     common_indep.h common_indep.c \
     cpphelp.cpp cpphelp.h \
     cryptcontroller.cpp cryptcontroller.h \
+    debug.h debug.cpp \
     dialogs.h \
     dispcache.h dispcache.cpp \
     eventsink.h \
diff --git a/src/common.cpp b/src/common.cpp
index f3f41af..9fcecbe 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -459,7 +459,7 @@ get_tmp_outfile (wchar_t *name, HANDLE *outHandle)
 
   auto outName = tmpPath + utf8Name;
 
-  log_mime_parser("%s:%s: Attachment candidate is %s",
+  log_data("%s:%s: Attachment candidate is %s",
                   SRCNAME, __func__, outName.c_str ());
 
   int tries = 1;
diff --git a/src/common_indep.c b/src/common_indep.c
index c0fe91f..aebd10c 100644
--- a/src/common_indep.c
+++ b/src/common_indep.c
@@ -478,286 +478,3 @@ generate_boundary (char *buffer)
 
   return buffer;
 }
-
-/* The malloced name of the logfile and the logging stream.  If
-   LOGFILE is NULL, no logging is done. */
-static char *logfile;
-static FILE *logfp;
-
-#ifdef HAVE_W32_SYSTEM
-
-/* Acquire the mutex for logging.  Returns 0 on success. */
-static int
-lock_log (void)
-{
-  int code = WaitForSingleObject (log_mutex, INFINITE);
-  return code != WAIT_OBJECT_0;
-}
-
-/* Release the mutex for logging. No error return is done because this
-   is a fatal error anyway and we have no means for proper
-   notification. */
-static void
-unlock_log (void)
-{
-  ReleaseMutex (log_mutex);
-}
-#endif
-
-const char *
-get_log_file (void)
-{
-  return logfile? logfile : "";
-}
-
-void
-set_log_file (const char *name)
-{
-#ifdef HAVE_W32_SYSTEM
-  if (!lock_log ())
-    {
-#endif
-      if (logfp)
-        {
-          fclose (logfp);
-          logfp = NULL;
-        }
-      xfree (logfile);
-      if (!name || *name == '\"' || !*name)
-        logfile = NULL;
-      else
-        logfile = xstrdup (name);
-#ifdef HAVE_W32_SYSTEM
-      unlock_log ();
-    }
-#endif
-}
-
-static void
-do_log (const char *fmt, va_list a, int w32err, int err,
-        const void *buf, size_t buflen)
-{
-  if (!logfile)
-    return;
-
-#ifdef HAVE_W32_SYSTEM
-  if (!opt.enable_debug)
-    return;
-
-  if (lock_log ())
-    return;
-#endif
-
-  if (!strcmp (logfile, "stdout"))
-    {
-      logfp = stdout;
-    }
-  else if (!strcmp (logfile, "stderr"))
-    {
-      logfp = stderr;
-    }
-  if (!logfp)
-    logfp = fopen (logfile, "a+");
-#ifdef HAVE_W32_SYSTEM
-  if (!logfp)
-    {
-      unlock_log ();
-      return;
-    }
-
-  char time_str[9];
-  SYSTEMTIME utc_time;
-  GetSystemTime (&utc_time);
-  if (GetTimeFormatA (LOCALE_INVARIANT,
-                      TIME_FORCE24HOURFORMAT | LOCALE_USE_CP_ACP,
-                      &utc_time,
-                      "HH:mm:ss",
-                      time_str,
-                      9))
-    {
-      fprintf (logfp, "%s/%lu/",
-               time_str,
-               (unsigned long)GetCurrentThreadId ());
-    }
-  else
-    {
-      fprintf (logfp, "unknown/%lu/",
-               (unsigned long)GetCurrentThreadId ());
-    }
-#endif
-
-  if (err == 1)
-    fputs ("ERROR/", logfp);
-  vfprintf (logfp, fmt, a);
-#ifdef HAVE_W32_SYSTEM
-  if (w32err)
-    {
-      char tmpbuf[256];
-
-      FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, w32err,
-                     MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
-                     tmpbuf, sizeof (tmpbuf)-1, NULL);
-      fputs (": ", logfp);
-      if (*tmpbuf && tmpbuf[strlen (tmpbuf)-1] == '\n')
-        tmpbuf[strlen (tmpbuf)-1] = 0;
-      if (*tmpbuf && tmpbuf[strlen (tmpbuf)-1] == '\r')
-        tmpbuf[strlen (tmpbuf)-1] = 0;
-      fprintf (logfp, "%s (%d)", tmpbuf, w32err);
-    }
-#endif
-  if (buf)
-    {
-      const unsigned char *p = (const unsigned char*)buf;
-
-      for ( ; buflen; buflen--, p++)
-        fprintf (logfp, "%02X", *p);
-      putc ('\n', logfp);
-    }
-  else if ( *fmt && fmt[strlen (fmt) - 1] != '\n')
-    putc ('\n', logfp);
-
-  fflush (logfp);
-#ifdef HAVE_W32_SYSTEM
-  unlock_log ();
-#endif
-}
-
-const char *
-log_srcname (const char *file)
-{
-  const char *s = strrchr (file, '/');
-  return s? s+1:file;
-}
-
-void
-log_debug (const char *fmt, ...)
-{
-  va_list a;
-
-  va_start (a, fmt);
-  do_log (fmt, a, 0, 0, NULL, 0);
-  va_end (a);
-}
-
-void
-log_error (const char *fmt, ...)
-{
-  va_list a;
-
-  va_start (a, fmt);
-  do_log (fmt, a, 0, 1, NULL, 0);
-  va_end (a);
-}
-
-void
-log_vdebug (const char *fmt, va_list a)
-{
-  do_log (fmt, a, 0, 0, NULL, 0);
-}
-
-void
-log_hexdump (const void *buf, size_t buflen, const char *fmt, ...)
-{
-  va_list a;
-
-  va_start (a, fmt);
-  do_log (fmt, a, 0, 2, buf, buflen);
-  va_end (a);
-}
-
-#ifdef HAVE_W32_SYSTEM
-void
-log_debug_w32 (int w32err, const char *fmt, ...)
-{
-  va_list a;
-
-  if (w32err == -1)
-    w32err = GetLastError ();
-
-  va_start (a, fmt);
-  do_log (fmt, a, w32err, 0, NULL, 0);
-  va_end (a);
-}
-
-void
-log_error_w32 (int w32err, const char *fmt, ...)
-{
-  va_list a;
-
-  if (w32err == -1)
-    w32err = GetLastError ();
-
-  va_start (a, fmt);
-  do_log (fmt, a, w32err, 1, NULL, 0);
-  va_end (a);
-}
-
-static void
-do_log_window_info (HWND window, int level)
-{
-  char buf[1024+1];
-  char name[200];
-  int nname;
-  char *pname;
-  DWORD pid;
-
-  if (!window)
-    return;
-
-  GetWindowThreadProcessId (window, &pid);
-  if (pid != GetCurrentProcessId ())
-    return;
-
-  memset (buf, 0, sizeof (buf));
-  GetWindowText (window, buf, sizeof (buf)-1);
-  nname = GetClassName (window, name, sizeof (name)-1);
-  if (nname)
-    pname = name;
-  else
-    pname = NULL;
-
-  if (level == -1)
-    log_debug ("  parent=%p/%lu (%s) `%s'", window, (unsigned long)pid,
-               pname? pname:"", buf);
-  else
-    log_debug ("    %*shwnd=%p/%lu (%s) `%s'", level*2, "", window,
-               (unsigned long)pid, pname? pname:"", buf);
-}
-
-
-/* Helper to log_window_hierarchy.  */
-static HWND
-do_log_window_hierarchy (HWND parent, int level)
-{
-  HWND child;
-
-  child = GetWindow (parent, GW_CHILD);
-  while (child)
-    {
-      do_log_window_info (child, level);
-      do_log_window_hierarchy (child, level+1);
-      child = GetNextWindow (child, GW_HWNDNEXT);
-    }
-
-  return NULL;
-}
-
-
-/* Print a debug message using the format string FMT followed by the
-   window hierarchy of WINDOW.  */
-void
-log_window_hierarchy (HWND window, const char *fmt, ...)
-{
-  va_list a;
-
-  va_start (a, fmt);
-  do_log (fmt, a, 0, 0, NULL, 0);
-  va_end (a);
-  if (window)
-    {
-      do_log_window_info (window, -1);
-      do_log_window_hierarchy (window, 0);
-    }
-}
-
-#endif
diff --git a/src/common_indep.h b/src/common_indep.h
index c78256f..8df77aa 100644
--- a/src/common_indep.h
+++ b/src/common_indep.h
@@ -30,6 +30,8 @@
 
 #include "xmalloc.h"
 
+#include "debug.h"
+
 #include "memdbg.h"
 
 #ifdef HAVE_W32_SYSTEM
@@ -217,27 +219,6 @@ struct b64_state_s
 };
 typedef struct b64_state_s b64_state_t;
 
-/* Bit values used for extra log file verbosity.  Value 1 is reserved
-   to enable debug menu options.
-
-   Note that the high values here are used for compatibility with
-   old howtos of how to enable debug flags. Based on the old
-   very split up logging categories.
-
-   Categories are meant to be:
-
-   DBG -> Generally useful information.
-   DBG_MEMORY -> Very verbose tracing of Releases / Allocs / Refs.
-   DBG_OOM -> Outlook Object Model events tracing.
-   DBG_DATA -> Including potentially private data and mime parser logging.
-
-   */
-#define DBG_MEMORY         (1<<5)
-#define DBG_MIME_PARSER    (1<<7)
-#define DBG_MIME_DATA      (1<<8)
-#define DBG_OOM            (1<<9)
-#define DBG_OOM_EXTRA      (1<<10)
-
 size_t qp_decode (char *buffer, size_t length, int *r_slbrk);
 char *qp_encode (const char *input, size_t length, size_t* outlen);
 void b64_init (b64_state_t *state);
@@ -264,46 +245,6 @@ char *trim_trailing_spaces (char *string);
               while(*_vptr) { *_vptr=0; _vptr++; } \
                   } while(0)
 
-#define debug_oom        ((opt.enable_debug & DBG_OOM) || \
-                          (opt.enable_debug & DBG_OOM_EXTRA))
-#define debug_oom_extra  (opt.enable_debug & DBG_OOM_EXTRA)
-void log_debug (const char *fmt, ...) __attribute__ ((format (printf,1,2)));
-void log_error (const char *fmt, ...) __attribute__ ((format (printf,1,2)));
-void log_vdebug (const char *fmt, va_list a);
-void log_debug_w32 (int w32err, const char *fmt,
-                    ...) __attribute__ ((format (printf,2,3)));
-void log_error_w32 (int w32err, const char *fmt,
-                    ...) __attribute__ ((format (printf,2,3)));
-void log_hexdump (const void *buf, size_t buflen, const char *fmt,
-                  ...)  __attribute__ ((format (printf,3,4)));
-
-#define log_oom if (opt.enable_debug & DBG_OOM) log_debug
-#define log_oom_extra if (opt.enable_debug & DBG_OOM_EXTRA) log_debug
-#define log_mime_parser if (opt.enable_debug & DBG_MIME_PARSER) log_debug
-#define log_mime_data if (opt.enable_debug & DBG_MIME_DATA) log_debug
-
-#define gpgol_release(X) \
-{ \
-  if (X && opt.enable_debug & DBG_OOM_EXTRA) \
-    { \
-      log_debug ("%s:%s:%i: Object: %p released ref: %lu \n", \
-                 SRCNAME, __func__, __LINE__, X, X->Release()); \
-      memdbg_released (X); \
-    } \
-  else if (X) \
-    { \
-      X->Release(); \
-    } \
-}
-
-const char *log_srcname (const char *s);
-#define SRCNAME log_srcname (__FILE__)
-
-#define TRACEPOINT log_debug ("%s:%s:%d: tracepoint\n", \
-                              SRCNAME, __func__, __LINE__);
-
-const char *get_log_file (void);
-void set_log_file (const char *name);
 void set_default_key (const char *name);
 
 /*-- Convenience macros. -- */
@@ -369,16 +310,6 @@ _gpgol_stpcpy (char *a, const char *b)
 #define stpcpy(a,b) _gpgol_stpcpy ((a), (b))
 #endif /*!HAVE_STPCPY*/
 
-#ifdef _WIN64
-#define SIZE_T_FORMAT "%I64u"
-#else
-# ifdef HAVE_W32_SYSTEM
-#  define SIZE_T_FORMAT "%u"
-# else
-#  define SIZE_T_FORMAT "%lu"
-# endif
-#endif
-
 /* The length of the boundary - the buffer needs to be allocated one
    byte larger. */
 #define BOUNDARYSIZE 20
diff --git a/src/debug.cpp b/src/debug.cpp
new file mode 100644
index 0000000..7f15550
--- /dev/null
+++ b/src/debug.cpp
@@ -0,0 +1,303 @@
+/* debug.cpp - Debugging / Log helpers for GpgOL
+ * Copyright (C) 2018 by by Intevation GmbH
+ *
+ * This file is part of GpgOL.
+ *
+ * GpgOL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GpgOL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common_indep.h"
+
+
+/* The malloced name of the logfile and the logging stream.  If
+   LOGFILE is NULL, no logging is done. */
+static char *logfile;
+static FILE *logfp;
+
+#ifdef HAVE_W32_SYSTEM
+
+/* Acquire the mutex for logging.  Returns 0 on success. */
+static int
+lock_log (void)
+{
+  int code = WaitForSingleObject (log_mutex, INFINITE);
+  return code != WAIT_OBJECT_0;
+}
+
+/* Release the mutex for logging. No error return is done because this
+   is a fatal error anyway and we have no means for proper
+   notification. */
+static void
+unlock_log (void)
+{
+  ReleaseMutex (log_mutex);
+}
+#endif
+
+const char *
+get_log_file (void)
+{
+  return logfile? logfile : "";
+}
+
+void
+set_log_file (const char *name)
+{
+#ifdef HAVE_W32_SYSTEM
+  if (!lock_log ())
+    {
+#endif
+      if (logfp)
+        {
+          fclose (logfp);
+          logfp = NULL;
+        }
+      xfree (logfile);
+      if (!name || *name == '\"' || !*name)
+        logfile = NULL;
+      else
+        logfile = xstrdup (name);
+#ifdef HAVE_W32_SYSTEM
+      unlock_log ();
+    }
+#endif
+}
+
+static void
+do_log (const char *fmt, va_list a, int w32err, int err,
+        const void *buf, size_t buflen)
+{
+  if (!logfile)
+    return;
+
+#ifdef HAVE_W32_SYSTEM
+  if (!opt.enable_debug)
+    return;
+
+  if (lock_log ())
+    return;
+#endif
+
+  if (!strcmp (logfile, "stdout"))
+    {
+      logfp = stdout;
+    }
+  else if (!strcmp (logfile, "stderr"))
+    {
+      logfp = stderr;
+    }
+  if (!logfp)
+    logfp = fopen (logfile, "a+");
+#ifdef HAVE_W32_SYSTEM
+  if (!logfp)
+    {
+      unlock_log ();
+      return;
+    }
+
+  char time_str[9];
+  SYSTEMTIME utc_time;
+  GetSystemTime (&utc_time);
+  if (GetTimeFormatA (LOCALE_INVARIANT,
+                      TIME_FORCE24HOURFORMAT | LOCALE_USE_CP_ACP,
+                      &utc_time,
+                      "HH:mm:ss",
+                      time_str,
+                      9))
+    {
+      fprintf (logfp, "%s/%lu/",
+               time_str,
+               (unsigned long)GetCurrentThreadId ());
+    }
+  else
+    {
+      fprintf (logfp, "unknown/%lu/",
+               (unsigned long)GetCurrentThreadId ());
+    }
+#endif
+
+  if (err == 1)
+    fputs ("ERROR/", logfp);
+  vfprintf (logfp, fmt, a);
+#ifdef HAVE_W32_SYSTEM
+  if (w32err)
+    {
+      char tmpbuf[256];
+
+      FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, w32err,
+                     MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
+                     tmpbuf, sizeof (tmpbuf)-1, NULL);
+      fputs (": ", logfp);
+      if (*tmpbuf && tmpbuf[strlen (tmpbuf)-1] == '\n')
+        tmpbuf[strlen (tmpbuf)-1] = 0;
+      if (*tmpbuf && tmpbuf[strlen (tmpbuf)-1] == '\r')
+        tmpbuf[strlen (tmpbuf)-1] = 0;
+      fprintf (logfp, "%s (%d)", tmpbuf, w32err);
+    }
+#endif
+  if (buf)
+    {
+      const unsigned char *p = (const unsigned char*)buf;
+
+      for ( ; buflen; buflen--, p++)
+        fprintf (logfp, "%02X", *p);
+      putc ('\n', logfp);
+    }
+  else if ( *fmt && fmt[strlen (fmt) - 1] != '\n')
+    putc ('\n', logfp);
+
+  fflush (logfp);
+#ifdef HAVE_W32_SYSTEM
+  unlock_log ();
+#endif
+}
+
+const char *
+log_srcname (const char *file)
+{
+  const char *s = strrchr (file, '/');
+  return s? s+1:file;
+}
+
+void
+log_debug (const char *fmt, ...)
+{
+  va_list a;
+
+  va_start (a, fmt);
+  do_log (fmt, a, 0, 0, NULL, 0);
+  va_end (a);
+}
+
+void
+log_error (const char *fmt, ...)
+{
+  va_list a;
+
+  va_start (a, fmt);
+  do_log (fmt, a, 0, 1, NULL, 0);
+  va_end (a);
+}
+
+void
+log_vdebug (const char *fmt, va_list a)
+{
+  do_log (fmt, a, 0, 0, NULL, 0);
+}
+
+void
+log_hexdump (const void *buf, size_t buflen, const char *fmt, ...)
+{
+  va_list a;
+
+  va_start (a, fmt);
+  do_log (fmt, a, 0, 2, buf, buflen);
+  va_end (a);
+}
+
+#ifdef HAVE_W32_SYSTEM
+void
+log_debug_w32 (int w32err, const char *fmt, ...)
+{
+  va_list a;
+
+  if (w32err == -1)
+    w32err = GetLastError ();
+
+  va_start (a, fmt);
+  do_log (fmt, a, w32err, 0, NULL, 0);
+  va_end (a);
+}
+
+void
+log_error_w32 (int w32err, const char *fmt, ...)
+{
+  va_list a;
+
+  if (w32err == -1)
+    w32err = GetLastError ();
+
+  va_start (a, fmt);
+  do_log (fmt, a, w32err, 1, NULL, 0);
+  va_end (a);
+}
+
+static void
+do_log_window_info (HWND window, int level)
+{
+  char buf[1024+1];
+  char name[200];
+  int nname;
+  char *pname;
+  DWORD pid;
+
+  if (!window)
+    return;
+
+  GetWindowThreadProcessId (window, &pid);
+  if (pid != GetCurrentProcessId ())
+    return;
+
+  memset (buf, 0, sizeof (buf));
+  GetWindowText (window, buf, sizeof (buf)-1);
+  nname = GetClassName (window, name, sizeof (name)-1);
+  if (nname)
+    pname = name;
+  else
+    pname = NULL;
+
+  if (level == -1)
+    log_debug ("  parent=%p/%lu (%s) `%s'", window, (unsigned long)pid,
+               pname? pname:"", buf);
+  else
+    log_debug ("    %*shwnd=%p/%lu (%s) `%s'", level*2, "", window,
+               (unsigned long)pid, pname? pname:"", buf);
+}
+
+
+/* Helper to log_window_hierarchy.  */
+static HWND
+do_log_window_hierarchy (HWND parent, int level)
+{
+  HWND child;
+
+  child = GetWindow (parent, GW_CHILD);
+  while (child)
+    {
+      do_log_window_info (child, level);
+      do_log_window_hierarchy (child, level+1);
+      child = GetNextWindow (child, GW_HWNDNEXT);
+    }
+
+  return NULL;
+}
+
+
+/* Print a debug message using the format string FMT followed by the
+   window hierarchy of WINDOW.  */
+void
+log_window_hierarchy (HWND window, const char *fmt, ...)
+{
+  va_list a;
+
+  va_start (a, fmt);
+  do_log (fmt, a, 0, 0, NULL, 0);
+  va_end (a);
+  if (window)
+    {
+      do_log_window_info (window, -1);
+      do_log_window_hierarchy (window, 0);
+    }
+}
+#endif
diff --git a/src/debug.h b/src/debug.h
new file mode 100644
index 0000000..36fafdc
--- /dev/null
+++ b/src/debug.h
@@ -0,0 +1,116 @@
+#ifndef DEBUG_H
+#define DEBUG_H
+/* debug.h - Debugging / Log helpers for GpgOL
+ * Copyright (C) 2018 by by Intevation GmbH
+ *
+ * This file is part of GpgOL.
+ *
+ * GpgOL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GpgOL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+}
+#endif
+#endif
+
+/* Bit values used for extra log file verbosity.  Value 1 is reserved
+   to enable debug menu options.
+
+   Note that the high values here are used for compatibility with
+   old howtos of how to enable debug flags. Based on the old
+   very split up logging categories.
+
+   Categories are meant to be:
+
+   DBG -> Generally useful information.
+   DBG_MEMORY -> Very verbose tracing of Releases / Allocs / Refs.
+   DBG_OOM -> Outlook Object Model events tracing.
+   DBG_DATA -> Including potentially private data and mime parser logging.
+
+   Common values are:
+   32 -> Only memory debugging.
+   544 -> OOM and Memory.
+   800 -> Full debugging.
+   */
+#define DBG_MEMORY         (1<<5) // 32
+#define DBG_MIME_PARSER    (1<<7) // 128 Unified as DBG_DATA
+#define DBG_MIME_DATA      (1<<8) // 256 Unified as DBG_DATA
+#define DBG_DATA           (DBG_MIME_PARSER | DBG_MIME_DATA)
+#define DBG_OOM_VAL        (1<<9) // 512 Unified as DBG_OOM
+#define DBG_OOM_EXTRA      (1<<10)// 1024 Unified as DBG_OOM
+#define DBG_OOM            (DBG_OOM_VAL | DBG_OOM_EXTRA)
+
+#define debug_oom        ((opt.enable_debug & DBG_OOM) || \
+                          (opt.enable_debug & DBG_OOM_EXTRA))
+#define debug_oom_extra  (opt.enable_debug & DBG_OOM_EXTRA)
+void log_debug (const char *fmt, ...) __attribute__ ((format (printf,1,2)));
+void log_error (const char *fmt, ...) __attribute__ ((format (printf,1,2)));
+void log_vdebug (const char *fmt, va_list a);
+void log_debug_w32 (int w32err, const char *fmt,
+                    ...) __attribute__ ((format (printf,2,3)));
+void log_error_w32 (int w32err, const char *fmt,
+                    ...) __attribute__ ((format (printf,2,3)));
+void log_hexdump (const void *buf, size_t buflen, const char *fmt,
+                  ...)  __attribute__ ((format (printf,3,4)));
+
+#define log_oom if (opt.enable_debug & DBG_OOM) log_debug
+#define log_oom_extra if (opt.enable_debug & DBG_OOM) log_debug
+#define log_mime_parser if (opt.enable_debug & DBG_DATA) log_debug
+#define log_data if (opt.enable_debug & DBG_DATA) log_debug
+#define log_mime_data if (opt.enable_debug & DBG_DATA) log_debug
+
+#define gpgol_release(X) \
+{ \
+  if (X && opt.enable_debug & DBG_OOM_EXTRA) \
+    { \
+      log_debug ("%s:%s:%i: Object: %p released ref: %lu \n", \
+                 SRCNAME, __func__, __LINE__, X, X->Release()); \
+      memdbg_released (X); \
+    } \
+  else if (X) \
+    { \
+      X->Release(); \
+    } \
+}
+
+const char *log_srcname (const char *s);
+#define SRCNAME log_srcname (__FILE__)
+
+#define TRACEPOINT log_debug ("%s:%s:%d: tracepoint\n", \
+                              SRCNAME, __func__, __LINE__);
+
+const char *get_log_file (void);
+void set_log_file (const char *name);
+
+#ifdef _WIN64
+#define SIZE_T_FORMAT "%I64u"
+#else
+# ifdef HAVE_W32_SYSTEM
+#  define SIZE_T_FORMAT "%u"
+# else
+#  define SIZE_T_FORMAT "%lu"
+# endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // DEBUG_H
diff --git a/src/keycache.cpp b/src/keycache.cpp
index 14afd01..75e317c 100644
--- a/src/keycache.cpp
+++ b/src/keycache.cpp
@@ -99,7 +99,7 @@ do_update (LPVOID arg)
 {
   auto args = std::unique_ptr<update_arg_t> ((update_arg_t*) arg);
 
-  log_mime_parser ("%s:%s updating: \"%s\" with protocol %s",
+  log_data ("%s:%s updating: \"%s\" with protocol %s",
                    SRCNAME, __func__, args->first.c_str (),
                    to_cstr (args->second));
 
@@ -146,7 +146,7 @@ do_import (LPVOID arg)
 
   const std::string mbox = args->first->m_mbox;
 
-  log_mime_parser ("%s:%s importing for: \"%s\" with data \n%s",
+  log_data ("%s:%s importing for: \"%s\" with data \n%s",
                    SRCNAME, __func__, mbox.c_str (),
                    args->second.c_str ());
   auto ctx = std::unique_ptr<GpgME::Context> (GpgME::Context::createForProtocol
@@ -397,25 +397,25 @@ public:
     const auto key = getSKey (addr, proto);
     if (key.isNull())
       {
-        log_mime_parser ("%s:%s: secret key for %s is null",
+        log_data ("%s:%s: secret key for %s is null",
                    SRCNAME, __func__, addr);
         return key;
       }
     if (!key.canReallySign())
       {
-        log_mime_parser ("%s:%s: Discarding key for %s because it can't sign",
+        log_data ("%s:%s: Discarding key for %s because it can't sign",
                    SRCNAME, __func__, addr);
         return GpgME::Key();
       }
     if (!key.hasSecret())
       {
-        log_mime_parser ("%s:%s: Discarding key for %s because it has no secret",
+        log_data ("%s:%s: Discarding key for %s because it has no secret",
                    SRCNAME, __func__, addr);
         return GpgME::Key();
       }
     if (in_de_vs_mode () && !key.isDeVs())
       {
-        log_mime_parser ("%s:%s: signing key for %s is not deVS",
+        log_data ("%s:%s: signing key for %s is not deVS",
                    SRCNAME, __func__, addr);
         return GpgME::Key();
       }
@@ -441,7 +441,7 @@ public:
             if (!overrides.empty())
               {
                 ret.insert (ret.end (), overrides.begin (), overrides.end ());
-                log_mime_parser ("%s:%s: Using overides for %s",
+                log_data ("%s:%s: Using overides for %s",
                                  SRCNAME, __func__, recip.c_str ());
                 continue;
               }
@@ -449,7 +449,7 @@ public:
         const auto key = getKey (recip.c_str (), proto);
         if (key.isNull())
           {
-            log_mime_parser ("%s:%s: No key for %s. no internal encryption",
+            log_data ("%s:%s: No key for %s. no internal encryption",
                        SRCNAME, __func__, recip.c_str ());
             return std::vector<GpgME::Key>();
           }
@@ -457,14 +457,14 @@ public:
         if (!key.canEncrypt() || key.isRevoked() ||
             key.isExpired() || key.isDisabled() || key.isInvalid())
           {
-            log_mime_parser ("%s:%s: Invalid key for %s. no internal encryption",
+            log_data ("%s:%s: Invalid key for %s. no internal encryption",
                        SRCNAME, __func__, recip.c_str ());
             return std::vector<GpgME::Key>();
           }
 
         if (in_de_vs_mode () && !key.isDeVs ())
           {
-            log_mime_parser ("%s:%s: key for %s is not deVS",
+            log_data ("%s:%s: key for %s is not deVS",
                        SRCNAME, __func__, recip.c_str ());
             return std::vector<GpgME::Key>();
           }
@@ -488,7 +488,7 @@ public:
           }
         if (!validEnough)
           {
-            log_mime_parser ("%s:%s: UID for %s does not have at least marginal trust",
+            log_data ("%s:%s: UID for %s does not have at least marginal trust",
                              SRCNAME, __func__, recip.c_str ());
             return std::vector<GpgME::Key>();
           }
@@ -525,7 +525,7 @@ public:
 
       auto it = m_fpr_map.find (primaryFpr);
 
-      log_mime_parser ("%s:%s \"%s\" updated.",
+      log_data ("%s:%s \"%s\" updated.",
                        SRCNAME, __func__, primaryFpr);
       if (it == m_fpr_map.end ())
         {
@@ -807,14 +807,14 @@ do_locate (LPVOID arg)
 
   const auto addr = args->m_mbox;
 
-  log_mime_parser ("%s:%s searching key for addr: \"%s\"",
+  log_data ("%s:%s searching key for addr: \"%s\"",
                    SRCNAME, __func__, addr.c_str());
 
   const auto k = GpgME::Key::locate (addr.c_str());
 
   if (!k.isNull ())
     {
-      log_mime_parser ("%s:%s found key for addr: \"%s\":%s",
+      log_data ("%s:%s found key for addr: \"%s\":%s",
                        SRCNAME, __func__, addr.c_str(),
                        k.primaryFingerprint());
       KeyCache::instance ()->setPgpKey (addr, k);
@@ -853,7 +853,7 @@ do_locate (LPVOID arg)
           if (key.isRevoked() || key.isExpired() ||
               key.isDisabled() || key.isInvalid())
             {
-              log_mime_parser ("%s:%s: Skipping invalid S/MIME key",
+              log_data ("%s:%s: Skipping invalid S/MIME key",
                                SRCNAME, __func__);
               continue;
             }
@@ -868,7 +868,7 @@ do_locate (LPVOID arg)
         }
       if (!candidate.isNull())
         {
-          log_mime_parser ("%s:%s found SMIME key for addr: \"%s\":%s",
+          log_data ("%s:%s found SMIME key for addr: \"%s\":%s",
                            SRCNAME, __func__, addr.c_str(),
                            candidate.primaryFingerprint());
           KeyCache::instance()->setSmimeKey (addr, candidate);
@@ -929,14 +929,14 @@ locate_secret (const char *addr, GpgME::Protocol proto)
             {
               std::stringstream ss;
               ss << key;
-              log_mime_parser ("%s:%s: Skipping invalid secret key %s",
+              log_data ("%s:%s: Skipping invalid secret key %s",
                                SRCNAME, __func__, ss.str().c_str());
             }
           continue;
         }
       if (proto == GpgME::OpenPGP)
         {
-          log_mime_parser ("%s:%s found pgp skey for addr: \"%s\":%s",
+          log_data ("%s:%s found pgp skey for addr: \"%s\":%s",
                            SRCNAME, __func__, mbox.c_str(),
                            key.primaryFingerprint());
           KeyCache::instance()->setPgpKeySecret (mbox, key);
@@ -944,7 +944,7 @@ locate_secret (const char *addr, GpgME::Protocol proto)
         }
       if (proto == GpgME::CMS)
         {
-          log_mime_parser ("%s:%s found cms skey for addr: \"%s\":%s",
+          log_data ("%s:%s found cms skey for addr: \"%s\":%s",
                            SRCNAME, __func__, mbox.c_str (),
                            key.primaryFingerprint());
           KeyCache::instance()->setSmimeKeySecret (mbox, key);
@@ -959,7 +959,7 @@ do_locate_secret (LPVOID arg)
 {
   auto args = std::unique_ptr<LocateArgs> ((LocateArgs *) arg);
 
-  log_mime_parser ("%s:%s searching secret key for addr: \"%s\"",
+  log_data ("%s:%s searching secret key for addr: \"%s\"",
                    SRCNAME, __func__, args->m_mbox.c_str ());
 
   locate_secret (args->m_mbox.c_str(), GpgME::OpenPGP);
diff --git a/src/mail.cpp b/src/mail.cpp
index 0e34085..1f48fd2 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1078,7 +1078,7 @@ Mail::decryptVerify_o ()
 
   m_parser = std::shared_ptr <ParseController> (new ParseController (cipherstream, m_type));
   m_parser->setSender(GpgME::UserID::addrSpecFromString(getSender_o ().c_str()));
-  log_mime_parser ("%s:%s: Parser for \"%s\" is %p",
+  log_data ("%s:%s: Parser for \"%s\" is %p",
                    SRCNAME, __func__, getSubject_o ().c_str(), m_parser.get());
   gpgol_release (cipherstream);
 
@@ -2957,7 +2957,7 @@ has_crypt_or_empty_body_oom (Mail *mail)
     }
   else
     {
-      log_mime_parser ("%s:%s: Body found in %p : \"%s\"",
+      log_data ("%s:%s: Body found in %p : \"%s\"",
                        SRCNAME, __func__, mail, body.c_str ());
     }
   return ret;
diff --git a/src/main.c b/src/main.c
index a0d7071..987b5fd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -232,7 +232,7 @@ read_options (void)
           else if (!strcmp (p, "mime-data"))
             opt.enable_debug |= DBG_MIME_DATA;
           else if (!strcmp (p, "oom"))
-            opt.enable_debug |= DBG_OOM;
+            opt.enable_debug |= DBG_OOM_VAL;
           else if (!strcmp (p, "oom-extra"))
             opt.enable_debug |= DBG_OOM_EXTRA;
           else
@@ -250,12 +250,10 @@ read_options (void)
      as the option for debuging was not read before. */
   free (val); val = NULL;
   if (opt.enable_debug)
-    log_debug ("enabled debug flags:%s%s%s%s%s\n",
+    log_debug ("enabled debug flags:%s%s%s\n",
                (opt.enable_debug & DBG_MEMORY)? " memory":"",
-               (opt.enable_debug & DBG_MIME_PARSER)? " mime-parser":"",
-               (opt.enable_debug & DBG_MIME_DATA)? " mime-data":"",
-               (opt.enable_debug & DBG_OOM)? " oom":"",
-               (opt.enable_debug & DBG_OOM_EXTRA)? " oom-extra":""
+               (opt.enable_debug & DBG_DATA)? " data":"",
+               (opt.enable_debug & DBG_OOM)? " oom":""
                );
 
   opt.enable_smime = get_conf_bool ("enableSmime", 0);
diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index ba49428..f629aca 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -129,7 +129,7 @@ debug_message_event (rfc822parse_event_t event)
     case RFC822PARSE_EPILOGUE: s= "Epilogue"; break;
     default: s= "[unknown event]"; break;
     }
-  log_mime_parser ("%s: rfc822 event %s\n", SRCNAME, s);
+  log_data ("%s: rfc822 event %s\n", SRCNAME, s);
 }
 
 /* Returns true if the BER encoded data in BUFFER is CMS signed data.
@@ -244,7 +244,7 @@ t2body (MimeDataProvider *provider, rfc822parse_t msg)
       ctsub  = "plain";
     }
 
-  log_mime_parser ("%s:%s: ctx=%p, ct=`%s/%s'\n",
+  log_data ("%s:%s: ctx=%p, ct=`%s/%s'\n",
                    SRCNAME, __func__, ctx, ctmain, ctsub);
 
   s = rfc822parse_query_parameter (field, "charset", 0);
@@ -337,7 +337,7 @@ t2body (MimeDataProvider *provider, rfc822parse_t msg)
          sig_data has not been set yet).  We also do this only while
          in verify mode because we don't want to write a full MUA.  */
       ctx->collect_signature = 1;
-      log_mime_parser ("%s:%s: Collecting signature.",
+      log_data ("%s:%s: Collecting signature.",
                        SRCNAME, __func__);
     }
   else if (ctx->nesting_level == 1 && ctx->is_encrypted
@@ -345,7 +345,7 @@ t2body (MimeDataProvider *provider, rfc822parse_t msg)
            && (ctx->protocol == PROTOCOL_OPENPGP
                && !strcmp (ctsub, "octet-stream")))
     {
-      log_mime_parser ("%s:%s: Collecting encrypted PGP data.",
+      log_data ("%s:%s: Collecting encrypted PGP data.",
                        SRCNAME, __func__);
       ctx->collect_crypto_data = 1;
     }
@@ -358,7 +358,7 @@ t2body (MimeDataProvider *provider, rfc822parse_t msg)
           && (!strcmp (ctsub, "pkcs7-mime")
               || !strcmp (ctsub, "x-pkcs7-mime")))
         {
-          log_mime_parser ("%s:%s: Collecting crypted S/MIME data.",
+          log_data ("%s:%s: Collecting crypted S/MIME data.",
                            SRCNAME, __func__);
           ctx->collect_crypto_data = 1;
         }
@@ -366,7 +366,7 @@ t2body (MimeDataProvider *provider, rfc822parse_t msg)
   rfc822parse_release_field (field); /* (Content-type) */
   ctx->in_data = 1;
 
-  log_mime_parser ("%s:%s: this body: nesting=%d partno=%d is_text=%d"
+  log_data ("%s:%s: this body: nesting=%d partno=%d is_text=%d"
                    " charset=\"%s\"\n body_seen=%d is_text_attachment=%d",
                    SRCNAME, __func__,
                    ctx->nesting_level, ctx->part_counter, is_text,
@@ -406,7 +406,7 @@ t2body (MimeDataProvider *provider, rfc822parse_t msg)
       ctx->current_attachment = provider->create_attachment();
       ctx->collect_body = 0;
       ctx->collect_html_body = 0;
-      log_mime_parser ("%s:%s: Collecting attachment.",
+      log_data ("%s:%s: Collecting attachment.",
                        SRCNAME, __func__);
     }
 
@@ -509,9 +509,9 @@ MimeDataProvider::MimeDataProvider(LPSTREAM stream, bool no_headers):
       log_error ("%s:%s called without stream ", SRCNAME, __func__);
       return;
     }
-  log_mime_parser ("%s:%s Collecting data.", SRCNAME, __func__);
+  log_data ("%s:%s Collecting data.", SRCNAME, __func__);
   collect_data (stream);
-  log_mime_parser ("%s:%s Data collected.", SRCNAME, __func__);
+  log_data ("%s:%s Data collected.", SRCNAME, __func__);
   gpgol_release (stream);
 }
 #endif
@@ -519,9 +519,9 @@ MimeDataProvider::MimeDataProvider(LPSTREAM stream, bool no_headers):
 MimeDataProvider::MimeDataProvider(FILE *stream, bool no_headers):
   MimeDataProvider(no_headers)
 {
-  log_mime_parser ("%s:%s Collecting data from file.", SRCNAME, __func__);
+  log_data ("%s:%s Collecting data from file.", SRCNAME, __func__);
   collect_data (stream);
-  log_mime_parser ("%s:%s Data collected.", SRCNAME, __func__);
+  log_data ("%s:%s Data collected.", SRCNAME, __func__);
 }
 
 MimeDataProvider::~MimeDataProvider()
@@ -558,7 +558,7 @@ MimeDataProvider::isSupported(GpgME::DataProvider::Operation op) const
 ssize_t
 MimeDataProvider::read(void *buffer, size_t size)
 {
-  log_mime_parser ("%s:%s: Reading: " SIZE_T_FORMAT "Bytes",
+  log_data ("%s:%s: Reading: " SIZE_T_FORMAT "Bytes",
                  SRCNAME, __func__, size);
   ssize_t bRead = m_crypto_data.read (buffer, size);
   if (opt.enable_debug & DBG_MIME_DATA && bRead)
@@ -717,7 +717,7 @@ MimeDataProvider::collect_input_lines(const char *input, size_t insize)
                 }
               else
                 {
-                  log_mime_parser ("%s:%s Collecting ended / failed.",
+                  log_data ("%s:%s Collecting ended / failed.",
                                    SRCNAME, __func__);
                 }
             }
@@ -791,11 +791,11 @@ MimeDataProvider::collect_data(LPSTREAM stream)
     {
       if (!bRead)
         {
-          log_mime_parser ("%s:%s: Input stream at EOF.",
+          log_data ("%s:%s: Input stream at EOF.",
                            SRCNAME, __func__);
           break;
         }
-      log_mime_parser ("%s:%s: Read %lu bytes.",
+      log_data ("%s:%s: Read %lu bytes.",
                        SRCNAME, __func__, bRead);
       allRead += bRead;
       if (first_read)
@@ -849,7 +849,7 @@ MimeDataProvider::collect_data(LPSTREAM stream)
           /* For S/MIME, Clearsigned, PGP MESSAGES we just pass everything
              on. Only the Multipart classes need parsing. And the output
              of course. */
-          log_mime_parser ("%s:%s: Just copying data.",
+          log_data ("%s:%s: Just copying data.",
                            SRCNAME, __func__);
           m_crypto_data.write ((void*)buf, (size_t) bRead);
           continue;
@@ -865,7 +865,7 @@ MimeDataProvider::collect_data(LPSTREAM stream)
                      SRCNAME, __func__);
           break;
         }
-      log_mime_parser ("%s:%s: Consumed: " SIZE_T_FORMAT " bytes",
+      log_data ("%s:%s: Consumed: " SIZE_T_FORMAT " bytes",
                        SRCNAME, __func__, m_rawbuf.size() - not_taken);
       m_rawbuf.erase (0, m_rawbuf.size() - not_taken);
     }
@@ -902,7 +902,7 @@ MimeDataProvider::collect_data(LPSTREAM stream)
             }
           if (line.find (':') != std::string::npos)
             {
-              log_mime_parser ("%s:%s: Removing comment '%s'.",
+              log_data ("%s:%s: Removing comment '%s'.",
                                SRCNAME, __func__, line.c_str ());
               continue;
             }
@@ -924,7 +924,7 @@ MimeDataProvider::collect_data(FILE *stream)
   size_t bRead;
   while ((bRead = fread (buf, 1, BUFSIZE, stream)) > 0)
     {
-      log_mime_parser ("%s:%s: Read " SIZE_T_FORMAT " bytes.",
+      log_data ("%s:%s: Read " SIZE_T_FORMAT " bytes.",
                        SRCNAME, __func__, bRead);
 
       if (m_collect_everything)
@@ -932,7 +932,7 @@ MimeDataProvider::collect_data(FILE *stream)
           /* For S/MIME, Clearsigned, PGP MESSAGES we just pass everything
              on. Only the Multipart classes need parsing. And the output
              of course. */
-          log_mime_parser ("%s:%s: Making verbatim copy" SIZE_T_FORMAT " bytes.",
+          log_data ("%s:%s: Making verbatim copy" SIZE_T_FORMAT " bytes.",
                            SRCNAME, __func__, bRead);
           m_crypto_data.write ((void*)buf, bRead);
           continue;
@@ -948,7 +948,7 @@ MimeDataProvider::collect_data(FILE *stream)
                      SRCNAME, __func__);
           return;
         }
-      log_mime_parser ("%s:%s: Consumed: " SIZE_T_FORMAT " bytes",
+      log_data ("%s:%s: Consumed: " SIZE_T_FORMAT " bytes",
                        SRCNAME, __func__, m_rawbuf.size() - not_taken);
       m_rawbuf.erase (0, m_rawbuf.size() - not_taken);
     }
@@ -960,7 +960,7 @@ ssize_t MimeDataProvider::write(const void *buffer, size_t bufSize)
     {
       /* Writing with collect everything one means that we are outputprovider.
          In this case for inline messages we want to collect everything. */
-      log_mime_parser ("%s:%s: Using complete input as body " SIZE_T_FORMAT " bytes.",
+      log_data ("%s:%s: Using complete input as body " SIZE_T_FORMAT " bytes.",
                        SRCNAME, __func__, bufSize);
       m_body += std::string ((const char *) buffer, bufSize);
       return bufSize;
@@ -976,7 +976,7 @@ ssize_t MimeDataProvider::write(const void *buffer, size_t bufSize)
                  SRCNAME, __func__);
       return bufSize;
     }
-  log_mime_parser ("%s:%s: Write Consumed: " SIZE_T_FORMAT " bytes",
+  log_data ("%s:%s: Write Consumed: " SIZE_T_FORMAT " bytes",
                    SRCNAME, __func__, m_rawbuf.size() - not_taken);
   m_rawbuf.erase (0, m_rawbuf.size() - not_taken);
   return bufSize;
@@ -997,7 +997,7 @@ MimeDataProvider::signature() const
 std::shared_ptr<Attachment>
 MimeDataProvider::create_attachment()
 {
-  log_mime_parser ("%s:%s: Creating attachment.",
+  log_data ("%s:%s: Creating attachment.",
                    SRCNAME, __func__);
 
   auto attach = std::shared_ptr<Attachment> (new Attachment());
@@ -1015,7 +1015,7 @@ MimeDataProvider::create_attachment()
         }
       else
         {
-          log_mime_parser ("%s:%s: Attachment filename: %s",
+          log_data ("%s:%s: Attachment filename: %s",
                            SRCNAME, __func__, m_mime_ctx->mimestruct_cur->filename);
           attach->set_display_name (m_mime_ctx->mimestruct_cur->filename);
         }
diff --git a/src/oomhelp.cpp b/src/oomhelp.cpp
index 0f832d8..2c162ab 100644
--- a/src/oomhelp.cpp
+++ b/src/oomhelp.cpp
@@ -1237,7 +1237,7 @@ try_resolve_group (LPDISPATCH addrEntry,
 
   if (type != DISTRIBUTION_LIST_ADDRESS_ENTRY_TYPE)
     {
-      log_mime_parser ("%s:%s: type of %s is %i",
+      log_data ("%s:%s: type of %s is %i",
                        SRCNAME, __func__, name.c_str(), type);
       return false;
     }
diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index 82d10e7..cc2ee33 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -83,7 +83,7 @@ ParseController::ParseController(LPSTREAM instream, msgtype_t type):
     m_block_html (false)
 {
   memdbg_ctor ("ParseController");
-  log_mime_parser ("%s:%s: Creating parser for stream: %p of type %i"
+  log_data ("%s:%s: Creating parser for stream: %p of type %i"
                    " expect no headers: %i expect no mime: %i",
                    SRCNAME, __func__, instream, type,
                    expect_no_headers (type), expect_no_mime (type));
@@ -98,7 +98,7 @@ ParseController::ParseController(FILE *instream, msgtype_t type):
     m_block_html (false)
 {
   memdbg_ctor ("ParseController");
-  log_mime_parser ("%s:%s: Creating parser for stream: %p of type %i",
+  log_data ("%s:%s: Creating parser for stream: %p of type %i",
                    SRCNAME, __func__, instream, type);
 }
 
@@ -649,7 +649,7 @@ ParseController::get_ultimate_keys()
               s_ultimate_keys.push_back (key);
               log_debug ("%s:%s: Adding ultimate uid.",
                          SRCNAME, __func__);
-              log_mime_parser ("%s:%s: Added uid %s.",
+              log_data ("%s:%s: Added uid %s.",
                                SRCNAME, __func__, uid.id());
               break;
             }

commit 9e42f7008b4d089546070cc4de4a461fb96e8e97
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 24 09:13:53 2018 +0200

    Remove obsolete logging categories
    
    * src/common_indep.h (DBG_COMMANDS, DBG_IOWORKER),
    (DBG_IOWORKER_EXTRA, DBG_FILTER, DBG_FILTER_EXTRA): Removed.
    * src/main.c (read_options): Remove handling of obsolete values.

diff --git a/src/common_indep.h b/src/common_indep.h
index 7175cf9..c78256f 100644
--- a/src/common_indep.h
+++ b/src/common_indep.h
@@ -218,21 +218,26 @@ struct b64_state_s
 typedef struct b64_state_s b64_state_t;
 
 /* Bit values used for extra log file verbosity.  Value 1 is reserved
-   to enable debug menu options.  */
-#define DBG_IOWORKER       (1<<1)
-#define DBG_IOWORKER_EXTRA (1<<2)
-#define DBG_FILTER         (1<<3)
-#define DBG_FILTER_EXTRA   (1<<4)
+   to enable debug menu options.
+
+   Note that the high values here are used for compatibility with
+   old howtos of how to enable debug flags. Based on the old
+   very split up logging categories.
+
+   Categories are meant to be:
+
+   DBG -> Generally useful information.
+   DBG_MEMORY -> Very verbose tracing of Releases / Allocs / Refs.
+   DBG_OOM -> Outlook Object Model events tracing.
+   DBG_DATA -> Including potentially private data and mime parser logging.
+
+   */
 #define DBG_MEMORY         (1<<5)
-#define DBG_COMMANDS       (1<<6)
 #define DBG_MIME_PARSER    (1<<7)
 #define DBG_MIME_DATA      (1<<8)
 #define DBG_OOM            (1<<9)
 #define DBG_OOM_EXTRA      (1<<10)
 
-/* Macros to used in conditionals to enable debug output.  */
-#define debug_commands    (opt.enable_debug & DBG_COMMANDS)
-
 size_t qp_decode (char *buffer, size_t length, int *r_slbrk);
 char *qp_encode (const char *input, size_t length, size_t* outlen);
 void b64_init (b64_state_t *state);
diff --git a/src/main.c b/src/main.c
index 8b08030..a0d7071 100644
--- a/src/main.c
+++ b/src/main.c
@@ -225,18 +225,8 @@ read_options (void)
             }
           if (isascii (*p) && isdigit (*p))
             opt.enable_debug |= strtoul (p, NULL, 0);
-          else if (!strcmp (p, "ioworker"))
-            opt.enable_debug |= DBG_IOWORKER;
-          else if (!strcmp (p, "ioworker-extra"))
-            opt.enable_debug |= DBG_IOWORKER_EXTRA;
-          else if (!strcmp (p, "filter"))
-            opt.enable_debug |= DBG_FILTER;
-          else if (!strcmp (p, "filter-extra"))
-            opt.enable_debug |= DBG_FILTER_EXTRA;
           else if (!strcmp (p, "memory"))
             opt.enable_debug |= DBG_MEMORY;
-          else if (!strcmp (p, "commands"))
-            opt.enable_debug |= DBG_COMMANDS;
           else if (!strcmp (p, "mime-parser"))
             opt.enable_debug |= DBG_MIME_PARSER;
           else if (!strcmp (p, "mime-data"))
@@ -260,13 +250,8 @@ read_options (void)
      as the option for debuging was not read before. */
   free (val); val = NULL;
   if (opt.enable_debug)
-    log_debug ("enabled debug flags:%s%s%s%s%s%s%s%s%s%s\n",
-               (opt.enable_debug & DBG_IOWORKER)? " ioworker":"",
-               (opt.enable_debug & DBG_IOWORKER_EXTRA)? " ioworker-extra":"",
-               (opt.enable_debug & DBG_FILTER)? " filter":"",
-               (opt.enable_debug & DBG_FILTER_EXTRA)? " filter-extra":"",
+    log_debug ("enabled debug flags:%s%s%s%s%s\n",
                (opt.enable_debug & DBG_MEMORY)? " memory":"",
-               (opt.enable_debug & DBG_COMMANDS)? " commands":"",
                (opt.enable_debug & DBG_MIME_PARSER)? " mime-parser":"",
                (opt.enable_debug & DBG_MIME_DATA)? " mime-data":"",
                (opt.enable_debug & DBG_OOM)? " oom":"",

-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am          |   1 +
 src/common.cpp           |   2 +-
 src/common_indep.c       | 283 -------------------------------------------
 src/common_indep.h       |  68 +----------
 src/debug.cpp            | 303 +++++++++++++++++++++++++++++++++++++++++++++++
 src/debug.h              | 116 ++++++++++++++++++
 src/keycache.cpp         |  40 +++----
 src/mail.cpp             |   4 +-
 src/main.c               |  25 +---
 src/mimedataprovider.cpp |  50 ++++----
 src/oomhelp.cpp          |   2 +-
 src/parsecontroller.cpp  |   6 +-
 12 files changed, 478 insertions(+), 422 deletions(-)
 create mode 100644 src/debug.cpp
 create mode 100644 src/debug.h


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list