summaryrefslogtreecommitdiffstats
path: root/kmail/kmdebug.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kmail/kmdebug.h
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail/kmdebug.h')
-rw-r--r--kmail/kmdebug.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/kmail/kmdebug.h b/kmail/kmdebug.h
new file mode 100644
index 00000000..e36621cf
--- /dev/null
+++ b/kmail/kmdebug.h
@@ -0,0 +1,62 @@
+// -*- c++ -*- convenience wrappers around kdDebug/kdWarning/etc
+
+#ifndef __KMAIL_KMDEBUG_H__
+#define __KMAIL_KMDEBUG_H__
+
+#include <kdebug.h>
+
+// Enable this to debug timing
+// #define DEBUG_TIMING
+
+// return type of kmDebug() depends on NDEBUG define:
+#ifdef NDEBUG
+# define kmail_dbgstream kndbgstream
+#else
+# define kmail_dbgstream kdbgstream
+#endif
+
+/** KMail's debug area code */
+static const int kmail_debug_area = 5006;
+
+static inline kmail_dbgstream kmDebug() { return kdDebug( kmail_debug_area ); }
+static inline kmail_dbgstream kmDebug( bool cond ) { return kdDebug( cond, kmail_debug_area ); }
+
+static inline kdbgstream kmWarning() { return kdWarning( kmail_debug_area ); }
+static inline kdbgstream kmWarning( bool cond ) { return kdWarning( cond, kmail_debug_area ); }
+
+static inline kdbgstream kmError() { return kdError( kmail_debug_area ); }
+static inline kdbgstream kmError( bool cond ) { return kdError( cond, kmail_debug_area ); }
+
+static inline kdbgstream kmFatal() { return kdFatal( kmail_debug_area ); }
+static inline kdbgstream kmFatal( bool cond ) { return kdFatal( cond, kmail_debug_area ); }
+
+// timing utilities
+#if !defined( NDEBUG ) && defined( DEBUG_TIMING )
+#include <qdatetime.h>
+#define CREATE_TIMER(x) int x=0, x ## _tmp=0; QTime x ## _tmp2
+#define START_TIMER(x) x ## _tmp2 = QTime::currentTime()
+#define GRAB_TIMER(x) x ## _tmp2.msecsTo(QTime::currentTime())
+#define END_TIMER(x) x += GRAB_TIMER(x); x ## _tmp++
+#define SHOW_TIMER(x) kdDebug(5006) << #x " == " << x << "(" << x ## _tmp << ")\n"
+#else
+#define CREATE_TIMER(x)
+#define START_TIMER(x)
+#define GRAB_TIMER(x)
+#define END_TIMER(x)
+#define SHOW_TIMER(x)
+#endif
+
+// profiling utilities
+#if !defined( NDEBUG )
+#define CREATE_COUNTER(x) int x ## _cnt=0
+#define RESET_COUNTER(x) x ## _cnt=0
+#define INC_COUNTER(x) x ## _cnt++
+#define SHOW_COUNTER(x) kdDebug(5006) << #x " == " << x ## _cnt << endl
+#else
+#define CREATE_COUNTER(x)
+#define RESET_COUNTER(x)
+#define INC_COUNTER(x)
+#define SHOW_COUNTER(x)
+#endif
+
+#endif // __KMAIL_KMDEBUG_H__