inc/cntdebug.h
changeset 53 e6aff7b69165
parent 50 77bc263e1626
child 61 d30183af6ca6
equal deleted inserted replaced
51:81c360d47083 53:e6aff7b69165
    21 
    21 
    22 #include <QDebug>   // QDebug
    22 #include <QDebug>   // QDebug
    23 #include <QtGlobal> // qDebug()
    23 #include <QtGlobal> // qDebug()
    24 
    24 
    25 // #define TRACK_MEMORY_LEAKS
    25 // #define TRACK_MEMORY_LEAKS
    26 // #define CNT_TRACE2FILE
    26 // #define TRACES
       
    27 // #define TRACE2FILE
    27 
    28 
    28 /*!
    29 /*!
    29     \def CNT_UNUSED(name)
    30     \def CNT_UNUSED(name)
    30     \brief Declares a single variable as unused when tracing is disabled.
    31     \brief Declares a single variable as unused when tracing is disabled.
    31 
    32 
   348 
   349 
   349     \param args Any number of arguments that can be streamed into a QTextStream, joined together
   350     \param args Any number of arguments that can be streamed into a QTextStream, joined together
   350     by the streaming operator <<.
   351     by the streaming operator <<.
   351 */
   352 */
   352 
   353 
   353 #if defined (_DEBUG) || defined (CNT_TRACE2FILE)
   354 // traces for debug builds by default, or if
       
   355 // TRACES macro is defined
       
   356 #if defined (_DEBUG) && !defined (TRACES)
       
   357 #define TRACES
       
   358 #endif
       
   359 
       
   360 #if defined (TRACES) || defined (TRACE2FILE)
   354     #define CNT_UNUSED(name)
   361     #define CNT_UNUSED(name)
   355     #define CNT_STATIC_ENTRY qDebug() << __PRETTY_FUNCTION__ << "entry";
   362     #define CNT_STATIC_ENTRY qDebug() << __PRETTY_FUNCTION__ << "entry";
   356     #define CNT_STATIC_ENTRY_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "entry," << args;
   363     #define CNT_STATIC_ENTRY_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "entry," << args;
   357     #define CNT_ENTRY qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this << "entry";
   364     #define CNT_ENTRY qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this << "entry";
   358     #define CNT_ENTRY_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this << "entry," << args;
   365     #define CNT_ENTRY_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this << "entry," << args;
   374     #define CNT_LOG
   381     #define CNT_LOG
   375     #define CNT_LOG_ARGS(args)
   382     #define CNT_LOG_ARGS(args)
   376     #define CNT_WARNING(args)
   383     #define CNT_WARNING(args)
   377     #define CNT_CRITICAL(args)
   384     #define CNT_CRITICAL(args)
   378     #define CNT_FATAL(args)
   385     #define CNT_FATAL(args)
   379 #endif // _DEBUG || CNT_TRACE2FILE
   386 #endif // TRACES || TRACE2FILE
   380     
   387     
   381 // for tracing memory leaks
   388 // for tracing memory leaks
   382 #ifdef TRACK_MEMORY_LEAKS
   389 #ifdef TRACK_MEMORY_LEAKS
   383     #include <hbapplication.h>
   390     #include <hbapplication.h>
   384 
   391 
   411     #define CNT_TRACK_QOBJECTLIFE(obj)
   418     #define CNT_TRACK_QOBJECTLIFE(obj)
   412     #define CNT_TRACK_QOBJECTLIVES(obj)
   419     #define CNT_TRACK_QOBJECTLIVES(obj)
   413 #endif
   420 #endif
   414 
   421 
   415 // filter phonebook app traces
   422 // filter phonebook app traces
   416 #ifdef CNT_TRACE2FILE
   423 #ifdef TRACE2FILE
   417     #include <QFile>
   424     #include <QFile>
   418     #include <QTextStream>
   425     #include <QTextStream>
   419     static void cntCustomLog2File(QtMsgType type, const char *msg)
   426     static void cntCustomLog2File(QtMsgType type, const char *msg)
   420     {   
   427     {   
   421         QFile logFile("c:/cnt_logs.log");
   428         QFile logFile("c:/cnt_logs.log");
   472         }
   479         }
   473         #define MSG_HANDLER cntCustomLog
   480         #define MSG_HANDLER cntCustomLog
   474     #else
   481     #else
   475         #define MSG_HANDLER 0
   482         #define MSG_HANDLER 0
   476     #endif  // Q_OS_SYMBIAN
   483     #endif  // Q_OS_SYMBIAN
   477 #endif  // CNT_TRACE2FILE
   484 #endif  // TRACE2FILE
   478 
   485 
   479 #endif // CNTDEBUG_H
   486 #endif // CNTDEBUG_H