347 |
349 |
348 \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 |
349 by the streaming operator <<. |
351 by the streaming operator <<. |
350 */ |
352 */ |
351 |
353 |
352 |
354 // traces for debug builds by default, or if |
353 #ifdef _DEBUG |
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; |
359 #define CNT_EXIT qDebug() << __PRETTY_FUNCTION__ << "exit"; |
366 #define CNT_EXIT qDebug() << __PRETTY_FUNCTION__ << "exit"; |
360 #define CNT_EXIT_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "exit," << args; |
367 #define CNT_EXIT_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "exit," << args; |
361 #define CNT_LOG qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this; |
368 #define CNT_LOG qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this; |
362 #define CNT_LOG_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << args; |
369 #define CNT_LOG_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << args; |
|
370 #define CNT_WARNING(args) qWarning() << __PRETTY_FUNCTION__ << args; |
|
371 #define CNT_CRITICAL(args) qCritical() << __PRETTY_FUNCTION__ << args; |
|
372 #define CNT_FATAL(args) qFatal() << __PRETTY_FUNCTION__ << args; |
363 #else |
373 #else |
364 #define CNT_UNUSED(name) Q_UNUSED(name) |
374 #define CNT_UNUSED(name) Q_UNUSED(name) |
365 #define CNT_STATIC_ENTRY |
375 #define CNT_STATIC_ENTRY |
366 #define CNT_STATIC_ENTRY_ARGS(args) |
376 #define CNT_STATIC_ENTRY_ARGS(args) |
367 #define CNT_ENTRY |
377 #define CNT_ENTRY |
368 #define CNT_ENTRY_ARGS(args) |
378 #define CNT_ENTRY_ARGS(args) |
369 #define CNT_EXIT |
379 #define CNT_EXIT |
370 #define CNT_EXIT_ARGS(args) |
380 #define CNT_EXIT_ARGS(args) |
371 #define CNT_LOG |
381 #define CNT_LOG |
372 #define CNT_LOG_ARGS(args) |
382 #define CNT_LOG_ARGS(args) |
373 #endif // _DEBUG |
383 #define CNT_WARNING(args) |
374 |
384 #define CNT_CRITICAL(args) |
|
385 #define CNT_FATAL(args) |
|
386 #endif // TRACES || TRACE2FILE |
|
387 |
375 // for tracing memory leaks |
388 // for tracing memory leaks |
376 #ifdef TRACK_MEMORY_LEAKS |
389 #ifdef TRACK_MEMORY_LEAKS |
377 #include <hbapplication.h> |
390 #include <hbapplication.h> |
378 |
391 |
379 #define CNT_TRACK_QOBJECTLIFE(obj) { new CntQObjectTracker(obj, __FILE__, __LINE__); } |
392 #define CNT_TRACK_QOBJECTLIFE(obj) { new CntQObjectTracker(obj, __FILE__, __LINE__); } |
404 #else |
417 #else |
405 #define CNT_TRACK_QOBJECTLIFE(obj) |
418 #define CNT_TRACK_QOBJECTLIFE(obj) |
406 #define CNT_TRACK_QOBJECTLIVES(obj) |
419 #define CNT_TRACK_QOBJECTLIVES(obj) |
407 #endif |
420 #endif |
408 |
421 |
|
422 // filter phonebook app traces |
|
423 #ifdef TRACE2FILE |
|
424 #include <QFile> |
|
425 #include <QTextStream> |
|
426 static void cntCustomLog2File(QtMsgType type, const char *msg) |
|
427 { |
|
428 QFile logFile("c:/cnt_logs.log"); |
|
429 if (!logFile.open(QIODevice::Append | QIODevice::Text)) |
|
430 { |
|
431 qFatal("error opening c:/cnt_logs.log file"); |
|
432 return; |
|
433 } |
|
434 |
|
435 QTextStream out(&logFile); |
|
436 switch (type) |
|
437 { |
|
438 case QtDebugMsg: |
|
439 out << "[CNT] Debug: " << msg; |
|
440 break; |
|
441 case QtWarningMsg: |
|
442 out << "[CNT] Warning: " << msg; |
|
443 break; |
|
444 case QtCriticalMsg: |
|
445 out << "[CNT] Critical: " << msg; |
|
446 break; |
|
447 case QtFatalMsg: |
|
448 out << "[CNT] Fatal: " << msg; |
|
449 abort(); |
|
450 break; |
|
451 default: |
|
452 out << "[CNT] No Log Selection Type: " << msg; |
|
453 break; |
|
454 } |
|
455 } |
|
456 #define MSG_HANDLER cntCustomLog2File |
|
457 #else |
|
458 #ifdef Q_OS_SYMBIAN |
|
459 #include <e32debug.h> |
|
460 static void cntCustomLog(QtMsgType type, const char *msg) |
|
461 { |
|
462 switch (type) { |
|
463 case QtDebugMsg: |
|
464 RDebug::Printf("[CNT] Debug: %s\n", msg); |
|
465 break; |
|
466 case QtWarningMsg: |
|
467 RDebug::Printf("[CNT] Warning: %s\n", msg); |
|
468 break; |
|
469 case QtCriticalMsg: |
|
470 RDebug::Printf("[CNT] Critical: %s\n", msg); |
|
471 break; |
|
472 case QtFatalMsg: |
|
473 RDebug::Printf("[CNT] Fatal: %s\n", msg); |
|
474 abort(); |
|
475 break; |
|
476 default: |
|
477 break; |
|
478 } |
|
479 } |
|
480 #define MSG_HANDLER cntCustomLog |
|
481 #else |
|
482 #define MSG_HANDLER 0 |
|
483 #endif // Q_OS_SYMBIAN |
|
484 #endif // TRACE2FILE |
|
485 |
409 #endif // CNTDEBUG_H |
486 #endif // CNTDEBUG_H |