[evolution-data-server] Allow debugging to be enabled with CAMEL_DEBUG environment variable
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Allow debugging to be enabled with CAMEL_DEBUG environment variable
- Date: Thu, 24 Jun 2010 13:01:58 +0000 (UTC)
commit 22c8df8da28c4146a151a10efbb80cd5222923d7
Author: David Woodhouse <David Woodhouse intel com>
Date: Sat Jun 19 10:51:22 2010 +0100
Allow debugging to be enabled with CAMEL_DEBUG environment variable
CAMEL_DEBUG=imapx will enable all debugging, or 'imapx:command',
'imapx:token' etc. will enable certain types.
Not entirely sure if 'debug' and 'extra' are the correct names for the
old 'd()' and 'e()' debug output...
camel/providers/imapx/camel-imapx-folder.c | 3 +-
camel/providers/imapx/camel-imapx-server.c | 8 +++---
camel/providers/imapx/camel-imapx-store-summary.c | 4 +-
camel/providers/imapx/camel-imapx-stream.c | 4 +-
camel/providers/imapx/camel-imapx-utils.c | 28 +++++++++++++++++++-
camel/providers/imapx/camel-imapx-utils.h | 13 +++++++++
camel/providers/imapx/camel-imapx-view-summary.c | 5 ++-
7 files changed, 52 insertions(+), 13 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 5db6560..987015a 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <glib/gi18n-lib.h>
+#include "camel-imapx-utils.h"
#include "camel-imapx-store.h"
#include "camel-imapx-folder.h"
#include "camel-imapx-summary.h"
@@ -37,7 +38,7 @@
#include <stdlib.h>
#include <string.h>
-#define d(x)
+#define d(x) camel_imapx_debug(debug, x)
G_DEFINE_TYPE (CamelIMAPXFolder, camel_imapx_folder, CAMEL_TYPE_OFFLINE_FOLDER)
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 2b6e518..c332c48 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -33,8 +33,8 @@
#include <ws2tcpip.h>
#endif
-#define c(x)
-#define e(x)
+#define c(x) camel_imapx_debug(command, x)
+#define e(x) camel_imapx_debug(extra, x)
#define CFS_CLASS(x) ((CamelFolderSummaryClass *)((CamelObject *)x)->klass)
@@ -859,8 +859,8 @@ imapx_command_start_next(CamelIMAPXServer *is, CamelException *ex)
c(printf("** Starting next command\n"));
if (is->literal != NULL || is->select_pending != NULL) {
- c(if (is->select_pending))
- c(printf("* no, waiting for literal/pending select '%s'\n", camel_folder_get_full_name (is->select_pending)));
+ c(if (is->select_pending)
+ printf("* no, waiting for literal/pending select '%s'\n", camel_folder_get_full_name (is->select_pending)));
/* TODO prolly start the store operations which do not require any folder to be selected */
return;
diff --git a/camel/providers/imapx/camel-imapx-store-summary.c b/camel/providers/imapx/camel-imapx-store-summary.c
index 9711bd9..83323bf 100644
--- a/camel/providers/imapx/camel-imapx-store-summary.c
+++ b/camel/providers/imapx/camel-imapx-store-summary.c
@@ -32,8 +32,8 @@
#include "camel-imapx-utils.h"
#include "camel-imapx-store-summary.h"
-#define d(x)
-#define io(x) /* io debug */
+#define d(x) camel_imapx_debug(debug, x)
+#define io(x) camel_imapx_debug(io, x)
#define CAMEL_IMAPX_STORE_SUMMARY_VERSION_0 (0)
diff --git a/camel/providers/imapx/camel-imapx-stream.c b/camel/providers/imapx/camel-imapx-stream.c
index d6102a6..5451469 100644
--- a/camel/providers/imapx/camel-imapx-stream.c
+++ b/camel/providers/imapx/camel-imapx-stream.c
@@ -35,8 +35,8 @@
#include "camel-imapx-stream.h"
#include "camel-imapx-exception.h"
-#define t(x)
-#define io(x)
+#define t(x) camel_imapx_debug(token, x)
+#define io(x) camel_imapx_debug(io, x)
#define CAMEL_IMAPX_STREAM_SIZE (4096)
#define CAMEL_IMAPX_STREAM_TOKEN (4096) /* maximum token size */
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index cdcbe69..5eb9eda 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -11,9 +11,32 @@
#include "camel-imapx-exception.h"
/* high-level parser state */
-#define p(x)
+#define p(x) camel_imapx_debug(parse, x)
/* debug */
-#define d(x)
+#define d(x) camel_imapx_debug(debug, x)
+
+gint camel_imapx_debug_flags;
+
+#define debug_set_flag(flag) do { \
+ if ((CAMEL_IMAPX_DEBUG_ALL & CAMEL_IMAPX_DEBUG_ ## flag) && \
+ camel_debug("imapx:" #flag)) \
+ camel_imapx_debug_flags |= CAMEL_IMAPX_DEBUG_ ## flag; \
+ } while (0)
+
+static void camel_imapx_set_debug_flags(void)
+{
+ if (camel_debug("imapx")) {
+ camel_imapx_debug_flags = CAMEL_IMAPX_DEBUG_ALL;
+ return;
+ }
+
+ debug_set_flag(command);
+ debug_set_flag(debug);
+ debug_set_flag(extra);
+ debug_set_flag(io);
+ debug_set_flag(token);
+ debug_set_flag(parse);
+}
#include "camel-imapx-tokenise.h"
#define SUBFOLDER_DIR_NAME "subfolders"
@@ -1897,6 +1920,7 @@ void imapx_utils_init(void)
imapx_specials[i] = v;
}
+ camel_imapx_set_debug_flags();
}
guchar imapx_is_mask(const gchar *p)
diff --git a/camel/providers/imapx/camel-imapx-utils.h b/camel/providers/imapx/camel-imapx-utils.h
index a87dd1f..e3eb2db 100644
--- a/camel/providers/imapx/camel-imapx-utils.h
+++ b/camel/providers/imapx/camel-imapx-utils.h
@@ -220,6 +220,19 @@ guchar imapx_is_mask(const gchar *p);
#define imapx_is_atom(s) (imapx_is_mask(s) & IMAPX_TYPE_ATOM_CHAR)
+extern gint camel_imapx_debug_flags;
+#define CAMEL_IMAPX_DEBUG_command (1<<0)
+#define CAMEL_IMAPX_DEBUG_debug (1<<1)
+#define CAMEL_IMAPX_DEBUG_extra (1<<2)
+#define CAMEL_IMAPX_DEBUG_io (1<<3)
+#define CAMEL_IMAPX_DEBUG_token (1<<4)
+#define CAMEL_IMAPX_DEBUG_parse (1<<5)
+
+/* Set this to zero to remove all debug output at build time */
+#define CAMEL_IMAPX_DEBUG_ALL ((1<<6)-1)
+
+#define camel_imapx_debug(type, ...) do { if (camel_imapx_debug_flags & CAMEL_IMAPX_DEBUG_ALL & CAMEL_IMAPX_DEBUG_ ## type) { __VA_ARGS__ ; } } while (0)
+
/* ********************************************************************** */
void imapx_utils_init(void);
diff --git a/camel/providers/imapx/camel-imapx-view-summary.c b/camel/providers/imapx/camel-imapx-view-summary.c
index 30703b3..9902deb 100644
--- a/camel/providers/imapx/camel-imapx-view-summary.c
+++ b/camel/providers/imapx/camel-imapx-view-summary.c
@@ -27,12 +27,13 @@
#include "camel-record.h"
#include "camel-imapx-view-summary.h"
+#include "camel-imapx-utils.h"
/* NB, this is only for the messy iterator_get interface, which could be better hidden */
#include "libdb/dist/db.h"
-#define io(x)
-#define d(x) (printf("%s(%d): ", __FILE__, __LINE__),(x))
+#define d(x) camel_imapx_debug(debug, x)
+#define io(x) camel_imapx_debug(io, x)
#define CVSD_CLASS(x) ((CamelViewSummaryDiskClass *)((CamelObject *)x)->klass)
#define CVS_CLASS(x) ((CamelViewSummaryClass *)((CamelObject *)x)->klass)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]