diff -r 7cbcb2896f0e -r a642906a277a inc/cntdebug.h --- a/inc/cntdebug.h Tue Jul 06 14:05:47 2010 +0300 +++ b/inc/cntdebug.h Wed Aug 18 09:39:00 2010 +0300 @@ -23,6 +23,8 @@ #include // qDebug() // #define TRACK_MEMORY_LEAKS +// #define TRACES +// #define TRACE2FILE /*! \def CNT_UNUSED(name) @@ -349,8 +351,13 @@ by the streaming operator <<. */ +// traces for debug builds by default, or if +// TRACES macro is defined +#if defined (_DEBUG) && !defined (TRACES) +#define TRACES +#endif -#ifdef _DEBUG +#if defined (TRACES) || defined (TRACE2FILE) #define CNT_UNUSED(name) #define CNT_STATIC_ENTRY qDebug() << __PRETTY_FUNCTION__ << "entry"; #define CNT_STATIC_ENTRY_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "entry," << args; @@ -360,6 +367,9 @@ #define CNT_EXIT_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "exit," << args; #define CNT_LOG qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this; #define CNT_LOG_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << args; + #define CNT_WARNING(args) qWarning() << __PRETTY_FUNCTION__ << args; + #define CNT_CRITICAL(args) qCritical() << __PRETTY_FUNCTION__ << args; + #define CNT_FATAL(args) qFatal() << __PRETTY_FUNCTION__ << args; #else #define CNT_UNUSED(name) Q_UNUSED(name) #define CNT_STATIC_ENTRY @@ -370,8 +380,11 @@ #define CNT_EXIT_ARGS(args) #define CNT_LOG #define CNT_LOG_ARGS(args) -#endif // _DEBUG - + #define CNT_WARNING(args) + #define CNT_CRITICAL(args) + #define CNT_FATAL(args) +#endif // TRACES || TRACE2FILE + // for tracing memory leaks #ifdef TRACK_MEMORY_LEAKS #include @@ -406,4 +419,68 @@ #define CNT_TRACK_QOBJECTLIVES(obj) #endif +// filter phonebook app traces +#ifdef TRACE2FILE + #include + #include + static void cntCustomLog2File(QtMsgType type, const char *msg) + { + QFile logFile("c:/cnt_logs.log"); + if (!logFile.open(QIODevice::Append | QIODevice::Text)) + { + qFatal("error opening c:/cnt_logs.log file"); + return; + } + + QTextStream out(&logFile); + switch (type) + { + case QtDebugMsg: + out << "[CNT] Debug: " << msg; + break; + case QtWarningMsg: + out << "[CNT] Warning: " << msg; + break; + case QtCriticalMsg: + out << "[CNT] Critical: " << msg; + break; + case QtFatalMsg: + out << "[CNT] Fatal: " << msg; + abort(); + break; + default: + out << "[CNT] No Log Selection Type: " << msg; + break; + } + } + #define MSG_HANDLER cntCustomLog2File +#else + #ifdef Q_OS_SYMBIAN + #include + static void cntCustomLog(QtMsgType type, const char *msg) + { + switch (type) { + case QtDebugMsg: + RDebug::Printf("[CNT] Debug: %s\n", msg); + break; + case QtWarningMsg: + RDebug::Printf("[CNT] Warning: %s\n", msg); + break; + case QtCriticalMsg: + RDebug::Printf("[CNT] Critical: %s\n", msg); + break; + case QtFatalMsg: + RDebug::Printf("[CNT] Fatal: %s\n", msg); + abort(); + break; + default: + break; + } + } + #define MSG_HANDLER cntCustomLog + #else + #define MSG_HANDLER 0 + #endif // Q_OS_SYMBIAN +#endif // TRACE2FILE + #endif // CNTDEBUG_H