13 * |
13 * |
14 * Description: Provides macros for logging |
14 * Description: Provides macros for logging |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
|
19 |
|
20 #ifndef __QTPHONELOG_H__ |
18 #ifndef __QTPHONELOG_H__ |
21 #define __QTPHONELOG_H__ |
19 #define __QTPHONELOG_H__ |
22 |
20 |
23 // INCLUDES |
21 // INCLUDES |
24 #include <e32def.h> |
22 #include <e32def.h> |
25 #include <QDebug> |
23 #include <QDebug> |
|
24 #include <QTime> |
|
25 #include <QString> |
|
26 |
|
27 #ifdef _DEBUG |
|
28 // simple class to do the timing. |
|
29 class ElapsedTimer{ |
|
30 public: |
|
31 ElapsedTimer(QString a): |
|
32 m_blockName(a){ |
|
33 qDebug() << m_blockName << " start"; |
|
34 m_startTime = QTime::currentTime(); |
|
35 } |
|
36 virtual ~ElapsedTimer(){ |
|
37 qDebug() << m_blockName << " end - elapsed time ms" << milliseconds(); |
|
38 } |
|
39 private: |
|
40 ulong milliseconds(){ |
|
41 QTime now = QTime::currentTime(); |
|
42 return ((now.second()*1000 + now.msec()) - |
|
43 ( m_startTime.second()*1000 + m_startTime.msec())); |
|
44 } |
|
45 private: |
|
46 QString m_blockName; |
|
47 QTime m_startTime; |
|
48 }; |
|
49 #endif |
26 |
50 |
27 // Q_FUNC_INFO does not print function signature in Symbian.. |
51 // Q_FUNC_INFO does not print function signature in Symbian.. |
28 |
52 |
29 #ifdef _DEBUG |
53 #ifdef _DEBUG |
30 #define PHONE_DEBUG(A) qDebug() <<A; |
54 #define PHONE_DEBUG(A) qDebug() <<A |
31 #define PHONE_DEBUG2(A, B) qDebug() <<A <<B |
55 #define PHONE_DEBUG2(A, B) qDebug() <<A <<B |
32 #define PHONE_DEBUG3(A, B, C) qDebug() <<A <<B <<C |
56 #define PHONE_DEBUG3(A, B, C) qDebug() <<A <<B <<C |
33 #define PHONE_DEBUG4(A, B, C, D) qDebug() <<A <<B <<C <<D |
57 #define PHONE_DEBUG4(A, B, C, D) qDebug() <<A <<B <<C <<D |
34 |
58 |
35 #ifdef Q_OS_SYMBIAN |
59 #ifdef Q_OS_SYMBIAN |
36 #define PHONE_TRACE qDebug() <<__PRETTY_FUNCTION__; |
60 #define PHONE_TRACE ElapsedTimer __elapsedTime(QString( "%1").arg( __PRETTY_FUNCTION__)); |
37 #define PHONE_TRACE1(A) qDebug() <<__PRETTY_FUNCTION__ <<A; |
61 #define PHONE_TRACE1(A) ElapsedTimer __elapsedTime1(QString( "%1 %2").arg( __PRETTY_FUNCTION__ ).arg(A)); |
38 #define PHONE_TRACE2(A, B) qDebug() <<__PRETTY_FUNCTION__ <<A <<B |
62 #define PHONE_TRACE2(A, B) ElapsedTimer __elapsedTime2(QString( "%1 %2 %3").arg( __PRETTY_FUNCTION__).arg(A).arg(B)); |
39 #define PHONE_TRACE3(A, B, C) qDebug() <<__PRETTY_FUNCTION__ <<A <<B <<C |
63 #define PHONE_TRACE3(A, B, C) ElapsedTimer __elapsedTime3(QString( "%1 %2 %3 %4").arg( __PRETTY_FUNCTION__).arg(A).arg(B).arg(C)); |
40 #define PHONE_TRACE4(A, B, C, D) qDebug() <<__PRETTY_FUNCTION__ <<A <<B <<C <<D |
64 #define PHONE_TRACE4(A, B, C, D) ElapsedTimer __elapsedTime4(QString( "%1 %2 %3 %4 %5").arg( __PRETTY_FUNCTION__).arg(A).arg(B).arg(C).arg(D)); |
41 #else //cannot use __PRETTY_FUNCTION__ in win32 |
65 #else //cannot use __PRETTY_FUNCTION__ in win32 |
42 #define PHONE_TRACE |
66 #define PHONE_TRACE |
43 #define PHONE_TRACE1(A) PHONE_DEBUG(A) |
67 #define PHONE_TRACE1(A) PHONE_DEBUG(A) |
44 #define PHONE_TRACE2(A, B) PHONE_DEBUG(A, B) |
68 #define PHONE_TRACE2(A, B) PHONE_DEBUG(A, B) |
45 #define PHONE_TRACE3(A, B, C) PHONE_DEBUG(A, B, C) |
69 #define PHONE_TRACE3(A, B, C) PHONE_DEBUG(A, B, C) |