From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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 --- kmail/kmdebug.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 kmail/kmdebug.h (limited to 'kmail/kmdebug.h') diff --git a/kmail/kmdebug.h b/kmail/kmdebug.h new file mode 100644 index 000000000..e36621cff --- /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 + +// 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 +#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__ -- cgit v1.2.1