62 // Macros for SWT component logging |
62 // Macros for SWT component logging |
63 // |
63 // |
64 |
64 |
65 #ifdef SWT_ENABLE_LOGGING |
65 #ifdef SWT_ENABLE_LOGGING |
66 |
66 |
|
67 #ifdef Q_CC_NOKIAX86 |
|
68 #define SWT_FUNC_INFO (QString(__FILE__ ":") += QString::number(__LINE__)).toLatin1().data() |
|
69 #else |
|
70 #define SWT_FUNC_INFO Q_FUNC_INFO |
|
71 #endif |
|
72 |
67 // Logging of a JNI native method call, JNI functions have this |
73 // Logging of a JNI native method call, JNI functions have this |
68 #define SWT_LOG_JNI_CALL() SwtScopeLog __swtScopeLogger(Q_FUNC_INFO, SwtLogJNIEnter, SwtLogJNIExit) |
74 #define SWT_LOG_JNI_CALL() SwtScopeLog __swtScopeLogger(SWT_FUNC_INFO, SwtLogJNIEnter, SwtLogJNIExit) |
69 |
75 |
70 // Logging of a function call other than the above |
76 // Logging of a function call other than the above |
71 #define SWT_LOG_FUNC_CALL() SwtScopeLog __swtScopeLogger(Q_FUNC_INFO, SwtLogFuncEnter, SwtLogFuncExit) |
77 #define SWT_LOG_FUNC_CALL() SwtScopeLog __swtScopeLogger(SWT_FUNC_INFO, SwtLogFuncEnter, SwtLogFuncExit) |
72 |
78 |
73 // Logging of a scope other than function call |
79 // Logging of a scope other than function call |
74 #define SWT_LOG_SCOPE_CALL() SwtScopeLog __swtScopeLogger(Q_FUNC_INFO, SwtLogScopeEnter, SwtLogScopeExit) |
80 #define SWT_LOG_SCOPE_CALL() SwtScopeLog __swtScopeLogger(SWT_FUNC_INFO, SwtLogScopeEnter, SwtLogScopeExit) |
75 |
81 |
76 // Logging of events |
82 // Logging of events |
77 #define SWT_LOG_EVENT_1(format, field1) SwtDataLog::LogData(format, field1, SwtLogEvent) |
83 #define SWT_LOG_EVENT_1(format, field1) SwtDataLog::LogData(format, field1, SwtLogEvent) |
78 #define SWT_LOG_EVENT_2(format, field1, field2) SwtDataLog::LogData(format, field1, field2, SwtLogEvent) |
84 #define SWT_LOG_EVENT_2(format, field1, field2) SwtDataLog::LogData(format, field1, field2, SwtLogEvent) |
79 #define SWT_LOG_EVENT_3(format, field1, field2, field3) SwtDataLog::LogData(format, field1, field2, field3, SwtLogEvent) |
85 #define SWT_LOG_EVENT_3(format, field1, field2, field3) SwtDataLog::LogData(format, field1, field2, field3, SwtLogEvent) |
109 |
115 |
110 #endif // SWT_ENABLE_LOGGING |
116 #endif // SWT_ENABLE_LOGGING |
111 |
117 |
112 // Log fatal error conditions, application will automatically terminate with return value 1 when using this |
118 // Log fatal error conditions, application will automatically terminate with return value 1 when using this |
113 #define SWT_LOG_FATAL_1(format, field1) SwtDataLog::LogData(format, field1, SwtLogFatal) |
119 #define SWT_LOG_FATAL_1(format, field1) SwtDataLog::LogData(format, field1, SwtLogFatal) |
114 |
|
115 // |
|
116 // Macros for Graphics component logging |
|
117 // |
|
118 |
|
119 // Logging of a JNI native method call, JNI functions have this |
|
120 //#define GFX_LOG_JNI_CALL() SwtScopeLog __swtScopeLogger(Q_FUNC_INFO, GfxLogJNIEnter, GfxLogJNIExit) |
|
121 |
|
122 |
120 |
123 /** |
121 /** |
124 * A class implementing logging of entering and leaving a scope. |
122 * A class implementing logging of entering and leaving a scope. |
125 * Additional type parameter is added for doing run time variation |
123 * Additional type parameter is added for doing run time variation |
126 * for different types of scope logs. |
124 * for different types of scope logs. |
127 */ |
125 */ |
128 class SwtScopeLog |
126 class SwtScopeLog |
129 { |
127 { |
130 public: |
128 public: |
131 SwtScopeLog( const char* aFunctionName, const SwtLogType& aEnterType, const SwtLogType& aExitType ); |
129 SwtScopeLog( const char* aFunctionName, const SwtLogType& aEnterType, const SwtLogType& aExitType ); |
132 virtual ~SwtScopeLog(); |
130 virtual ~SwtScopeLog(); |
133 protected: |
131 protected: |
134 SwtScopeLog(); |
132 SwtScopeLog(); |
135 private: |
133 private: |
136 QString* mFunctionName; |
134 QString* mFunctionName; |
137 SwtLogType mExitLogType; |
135 SwtLogType mExitLogType; |
138 }; |
136 }; |
139 |
137 |
140 /** |
138 /** |
141 * Functions for logging data using the standard printf conventions. |
139 * Functions for logging data using the standard printf conventions. |
142 * Each function takes the format string and the parameters. Additional type parameter |
140 * Each function takes the format string and the parameters. Additional type parameter |
202 { |
200 { |
203 qFatal( "%s %s %s: %s", SWT_LOG_TIMESTAMP, logComponentName, dataDescription, aLogEntry ); |
201 qFatal( "%s %s %s: %s", SWT_LOG_TIMESTAMP, logComponentName, dataDescription, aLogEntry ); |
204 } |
202 } |
205 else |
203 else |
206 { |
204 { |
207 qDebug( "%s %s %s: %s", SWT_LOG_TIMESTAMP, logComponentName, dataDescription, aLogEntry ); |
205 qDebug( "%s %s %s: %s", SWT_LOG_TIMESTAMP, logComponentName, dataDescription, aLogEntry ); |
208 } |
206 } |
209 } |
207 } |
210 |
208 |
211 template<class T1> |
209 template<class T1> |
212 void LogData( const char* format, const T1& data1, const SwtLogType& type ) |
210 void LogData( const char* format, const T1& data1, const SwtLogType& type ) |
213 { |
211 { |
214 QString str; |
212 QString str; |
215 DoLog( str.sprintf( format, data1 ).toLatin1().data(), type ); |
213 DoLog( str.sprintf( format, data1 ).toLatin1().data(), type ); |
216 } |
214 } |
217 |
215 |
218 template<class T1, class T2> |
216 template<class T1, class T2> |
219 void LogData( const char* format, const T1& data1, const T2& data2, const SwtLogType& type ) |
217 void LogData( const char* format, const T1& data1, const T2& data2, const SwtLogType& type ) |
220 { |
218 { |
221 QString str; |
219 QString str; |
222 DoLog( str.sprintf( format, data1, data2 ).toLatin1().data(), type ); |
220 DoLog( str.sprintf( format, data1, data2 ).toLatin1().data(), type ); |
223 } |
221 } |
224 |
222 |
225 template<class T1, class T2, class T3> |
223 template<class T1, class T2, class T3> |
226 void LogData( const char* format, const T1& data1, const T2& data2, const T3& data3, const SwtLogType& type ) |
224 void LogData( const char* format, const T1& data1, const T2& data2, const T3& data3, const SwtLogType& type ) |
227 { |
225 { |
228 QString str; |
226 QString str; |
229 DoLog( str.sprintf( format, data1, data2, data3 ).toLatin1().data(), type ); |
227 DoLog( str.sprintf( format, data1, data2, data3 ).toLatin1().data(), type ); |
230 } |
228 } |
231 |
229 |
232 template<class T1, class T2, class T3, class T4> |
230 template<class T1, class T2, class T3, class T4> |
233 void LogData( const char* format, const T1& data1, const T2& data2, const T3& data3, const T4& data4, const SwtLogType& type ) |
231 void LogData( const char* format, const T1& data1, const T2& data2, const T3& data3, const T4& data4, const SwtLogType& type ) |
234 { |
232 { |
235 QString str; |
233 QString str; |
236 DoLog( str.sprintf( format, data1, data2, data3, data4 ).toLatin1().data(), type ); |
234 DoLog( str.sprintf( format, data1, data2, data3, data4 ).toLatin1().data(), type ); |
237 } |
235 } |
238 |
236 |
239 template<class T1, class T2, class T3, class T4, class T5> |
237 template<class T1, class T2, class T3, class T4, class T5> |
240 void LogData( const char* format, const T1& data1, const T2& data2, const T3& data3, const T4& data4, const T5& data5, const SwtLogType& type ) |
238 void LogData( const char* format, const T1& data1, const T2& data2, const T3& data3, const T4& data4, const T5& data5, const SwtLogType& type ) |
241 { |
239 { |
242 QString str; |
240 QString str; |
243 DoLog( str.sprintf( format, data1, data2, data3, data4, data5 ).toLatin1().data(), type ); |
241 DoLog( str.sprintf( format, data1, data2, data3, data4, data5 ).toLatin1().data(), type ); |
244 } |
242 } |
245 } |
243 } |
246 |
244 |
247 }} |
245 }} |
248 |
246 |
249 #endif // SWTLOG_H_ |
247 #endif // SWTLOG_H_ |