19 #define EMAILTRACE_H |
19 #define EMAILTRACE_H |
20 |
20 |
21 #include "emailtraceconfig.hrh" |
21 #include "emailtraceconfig.hrh" |
22 |
22 |
23 #ifdef TRACE_INTO_FILE |
23 #ifdef TRACE_INTO_FILE |
24 #include "cmaillogger.h" |
|
25 #include <flogger.h> // RFileLogger |
24 #include <flogger.h> // RFileLogger |
26 #else |
25 #else |
27 #include <e32debug.h> // RDebug |
26 #include <e32debug.h> // RDebug |
28 #endif |
27 #endif |
29 |
28 |
30 /** |
29 /** |
31 * Constants |
30 * Constants |
32 */ |
31 */ |
33 #if defined(TRACE_INTO_FILE) |
32 #ifdef TRACE_INTO_FILE |
34 |
33 |
35 _LIT( KEmailDir, "email" ); |
34 _LIT( KEmailDir, "email" ); |
36 _LIT( KEmailTraceFile, "email.txt" ); |
35 _LIT( KEmailTraceFile, "email.txt" ); |
37 |
36 |
38 #endif |
37 #endif |
39 |
38 |
40 #if defined(TRACE_FILE_LIMIT_SIZE) |
|
41 #define CMAIL_LOG_CLOSE CmailLogger::Close(); |
|
42 #define CMAILLOGBUFFERSIZE 120 |
|
43 #else |
|
44 #define CMAIL_LOG_CLOSE |
|
45 #endif |
|
46 |
|
47 //----------------------------------------------------------------------------- |
39 //----------------------------------------------------------------------------- |
48 // Error trace macros |
40 // Error trace macros |
49 //----------------------------------------------------------------------------- |
41 //----------------------------------------------------------------------------- |
50 // |
42 // |
51 |
|
52 #ifdef ERROR_TRACE |
43 #ifdef ERROR_TRACE |
53 |
44 |
54 /** |
45 /** |
55 * Error trace definitions. Does not automatically log the error code! |
46 * Error trace definitions. Does not automatically log the error code! |
56 */ |
47 */ |
57 #if defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE) |
48 #ifdef TRACE_INTO_FILE |
58 |
49 |
59 #define ERROR( aErr, aMsg )\ |
50 #define ERROR( aErr, aMsg )\ |
60 {\ |
51 {\ |
61 if( aErr != KErrNone )\ |
52 if( aErr != KErrNone )\ |
62 {\ |
53 {\ |
88 RFileLogger::WriteFormat( KEmailDir, KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2, aP3 );\ |
79 RFileLogger::WriteFormat( KEmailDir, KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2, aP3 );\ |
89 }\ |
80 }\ |
90 } |
81 } |
91 #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg ) |
82 #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg ) |
92 #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 ) |
83 #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 ) |
93 #endif |
84 |
94 #if defined(TRACE_INTO_FILE) && defined(TRACE_FILE_LIMIT_SIZE) |
85 #else//TRACE_INTO_FILE not defined |
95 |
|
96 #define ERROR( aErr, aMsg )\ |
|
97 {\ |
|
98 if( aErr != KErrNone )\ |
|
99 {\ |
|
100 _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KMsg(); if ( KMsg().Size() < buf.MaxSize() ) { CmailLogger::Write( buf ); }}\ |
|
101 } |
|
102 |
|
103 #define ERROR_1( aErr, aMsg, aP1 )\ |
|
104 {\ |
|
105 if( aErr != KErrNone )\ |
|
106 {\ |
|
107 _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8(); if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1 ); CmailLogger::Write( buf ); } }\ |
|
108 } |
|
109 #define ERROR_2( aErr, aMsg, aP1, aP2 )\ |
|
110 {\ |
|
111 if( aErr != KErrNone )\ |
|
112 {\ |
|
113 _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8(); if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1, aP2 ); CmailLogger::Write( buf ); }} \ |
|
114 } |
|
115 #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\ |
|
116 {\ |
|
117 if( aErr != KErrNone )\ |
|
118 {\ |
|
119 _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8(); if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1, aP2, aP3 ); CmailLogger::Write( buf ); }}\ |
|
120 } |
|
121 #endif |
|
122 #if !defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE) |
|
123 |
86 |
124 #define ERROR( aErr, aMsg )\ |
87 #define ERROR( aErr, aMsg )\ |
125 {\ |
88 {\ |
126 if( aErr != KErrNone )\ |
89 if( aErr != KErrNone )\ |
127 {\ |
90 {\ |
163 #define ERROR_GEN( aMsg ) |
126 #define ERROR_GEN( aMsg ) |
164 #define ERROR_GEN_1( aMsg, aP1 ) |
127 #define ERROR_GEN_1( aMsg, aP1 ) |
165 |
128 |
166 #endif//ERROR_TRACE |
129 #endif//ERROR_TRACE |
167 |
130 |
168 |
|
169 //----------------------------------------------------------------------------- |
131 //----------------------------------------------------------------------------- |
170 // Info trace macros |
132 // Info trace macros |
171 //----------------------------------------------------------------------------- |
133 //----------------------------------------------------------------------------- |
172 // |
134 // |
173 #if defined(INFO_TRACE) |
135 #ifdef INFO_TRACE |
174 |
136 |
175 /** |
137 /** |
176 * Info log message definitions. |
138 * Info log message definitions. |
177 */ |
139 */ |
178 #if defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE) |
140 #ifdef TRACE_INTO_FILE |
179 |
141 |
180 #define INFO( aMsg )\ |
142 #define INFO( aMsg )\ |
181 {\ |
143 {\ |
182 _LIT( KMsg, aMsg );\ |
144 _LIT( KMsg, aMsg );\ |
183 RFileLogger::Write( KEmailDir, KEmailTraceFile, EFileLoggingModeAppend, KMsg );\ |
145 RFileLogger::Write( KEmailDir, KEmailTraceFile, EFileLoggingModeAppend, KMsg );\ |
195 #define INFO_3( aMsg, aP1, aP2, aP3 )\ |
157 #define INFO_3( aMsg, aP1, aP2, aP3 )\ |
196 {\ |
158 {\ |
197 _LIT( KMsg, aMsg );\ |
159 _LIT( KMsg, aMsg );\ |
198 RFileLogger::WriteFormat( KEmailDir, KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2, aP3 );\ |
160 RFileLogger::WriteFormat( KEmailDir, KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2, aP3 );\ |
199 } |
161 } |
200 #endif // // TRACE_INTO_FILE && TRACE_FILE_LIMIT_SIZE |
162 |
201 |
163 #else//TRACE_INTO_FILE not defined |
202 #if defined(TRACE_INTO_FILE) && defined(TRACE_FILE_LIMIT_SIZE) |
164 |
203 #define CMAIL_LOG_INIT |
|
204 |
|
205 #define INFO( aMsg )\ |
165 #define INFO( aMsg )\ |
206 {\ |
166 {\ |
207 _LIT8( KMsg, aMsg );\ |
167 _LIT( KMsg, aMsg ); RDebug::Print( KMsg );\ |
208 CmailLogger::Write( KMsg );\ |
|
209 } |
168 } |
210 #define INFO_1( aMsg, aP1 )\ |
169 #define INFO_1( aMsg, aP1 )\ |
211 { _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8();\ |
170 {\ |
212 if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1 ); }\ |
171 _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1 );\ |
213 CmailLogger::Write( buf ); } |
172 } |
214 #define INFO_2( aMsg, aP1, aP2 )\ |
173 #define INFO_2( aMsg, aP1, aP2 )\ |
215 { _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8();\ |
174 {\ |
216 if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1,aP2 ); }\ |
175 _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2 );\ |
217 CmailLogger::Write( buf ); } |
176 } |
218 #define INFO_3( aMsg, aP1, aP2, aP3 )\ |
177 #define INFO_3( aMsg, aP1, aP2, aP3 )\ |
219 { _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8();\ |
|
220 if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1,aP2,aP3 ); }\ |
|
221 CmailLogger::Write( buf ); } |
|
222 #endif // TRACE_INTO_FILE && TRACE_FILE_LIMIT_SIZE |
|
223 #if !defined(TRACE_INTO_FILE) |
|
224 |
|
225 #define INFO( aMsg )\ |
|
226 {\ |
|
227 _LIT( KMsg, aMsg ); RDebug::Print( KMsg );\ |
|
228 } |
|
229 #define INFO_1( aMsg, aP1 )\ |
|
230 {\ |
|
231 _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1 );\ |
|
232 } |
|
233 #define INFO_2( aMsg, aP1, aP2 )\ |
|
234 {\ |
|
235 _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2 );\ |
|
236 } |
|
237 #define INFO_3( aMsg, aP1, aP2, aP3 )\ |
|
238 {\ |
178 {\ |
239 _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2, aP3 );\ |
179 _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2, aP3 );\ |
240 } |
180 } |
241 |
181 |
242 #endif//TRACE_INTO_FILE |
182 #endif//TRACE_INTO_FILE |
243 |
183 |
244 #else//INFO_TRACE not defined |
184 #else//INFO_TRACE not defined |
245 |
185 |
246 #define CMAIL_LOG_INIT |
|
247 #define CMAIL_LOG_CLOSE |
|
248 #define INFO( aMsg ) |
186 #define INFO( aMsg ) |
249 #define INFO_1( aMsg, aP1 ) |
187 #define INFO_1( aMsg, aP1 ) |
250 #define INFO_2( aMsg, aP1, aP2 ) |
188 #define INFO_2( aMsg, aP1, aP2 ) |
251 #define INFO_3( aMsg, aP1, aP2, aP3 ) |
189 #define INFO_3( aMsg, aP1, aP2, aP3 ) |
252 |
190 |
254 |
192 |
255 //----------------------------------------------------------------------------- |
193 //----------------------------------------------------------------------------- |
256 // Function trace macros |
194 // Function trace macros |
257 //----------------------------------------------------------------------------- |
195 //----------------------------------------------------------------------------- |
258 // |
196 // |
259 |
197 #ifdef FUNC_TRACE |
260 #if defined (FUNC_TRACE) |
|
261 |
198 |
262 // Constants |
199 // Constants |
263 _LIT8( KEllipse, "(" ); |
200 _LIT8( KEllipse, "(" ); |
264 |
201 |
265 // |
202 /** |
266 // Function logging definitions. |
203 * Function logging definitions. |
267 // |
204 */ |
268 |
205 #ifdef TRACE_INTO_FILE |
269 |
206 |
270 #if defined(TRACE_FILE_LIMIT_SIZE) |
|
271 #define FUNC( aMsg, aP1 )\ |
207 #define FUNC( aMsg, aP1 )\ |
272 {\ |
|
273 _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8(); if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1 ); }CmailLogger::Write( buf ); } |
|
274 #endif |
|
275 #if defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE) |
|
276 #define FUNC( aMsg, aP1 )\ |
|
277 {\ |
208 {\ |
278 _LIT8( KMsg, aMsg ); RFileLogger::WriteFormat( KEmailDir, KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1 );\ |
209 _LIT8( KMsg, aMsg ); RFileLogger::WriteFormat( KEmailDir, KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1 );\ |
279 } |
210 }\ |
280 #endif |
211 |
281 #if !defined(TRACE_INTO_FILE) |
212 #else//TRACE_INTO_FILE not defined |
|
213 |
282 #define FUNC( aMsg, aP1 )\ |
214 #define FUNC( aMsg, aP1 )\ |
283 {\ |
215 {\ |
284 RDebug::Printf( aMsg, aP1 );\ |
216 RDebug::Printf( aMsg, aP1 );\ |
285 }\ |
217 }\ |
286 |
218 |
287 #endif//TRACE_INTO_FILE |
219 #endif//TRACE_INTO_FILE |
288 |
220 |
289 /** |
221 /** |
290 * Function trace helper class. |
222 * Function trace helper class. |
291 */ |
223 */ |
292 class TFuncLog |
224 class TFuncLog |
293 { |
225 { |
297 TInt pos = iFunc.Find( KEllipse ); |
229 TInt pos = iFunc.Find( KEllipse ); |
298 if( pos != KErrNotFound ) |
230 if( pos != KErrNotFound ) |
299 { |
231 { |
300 iFunc.Set( iFunc.Left( iFunc.Find( KEllipse ) ) ); |
232 iFunc.Set( iFunc.Left( iFunc.Find( KEllipse ) ) ); |
301 } |
233 } |
302 #if defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE) |
234 #ifdef TRACE_INTO_FILE |
303 |
235 |
304 //"CMAIL" string is added in the beginning of every trace |
236 //"CMAIL" string is added in the beginning of every trace |
305 //line for filtering purposes |
237 //line for filtering purposes |
306 FUNC( "CMAIL %S <", &iFunc ); |
238 FUNC( "CMAIL %S <", &iFunc ); |
307 #endif |
239 |
308 #if defined(TRACE_INTO_FILE) && defined(TRACE_FILE_LIMIT_SIZE) |
240 #else//TRACE_INTO_FILE notdefined |
309 TBuf8<CMAILLOGBUFFERSIZE> buf(iFunc); |
|
310 buf.Append(_L("<")); |
|
311 CmailLogger::Write( buf ); |
|
312 #endif |
|
313 #if !defined(TRACE_INTO_FILE) |
|
314 |
241 |
315 FUNC( "CMAIL %s <", iFunc.Ptr() ); |
242 FUNC( "CMAIL %s <", iFunc.Ptr() ); |
316 |
243 |
317 #endif//TRACE_INTO_FILE |
244 #endif//TRACE_INTO_FILE |
318 } |
245 } |
319 inline ~TFuncLog() |
246 inline ~TFuncLog() |
320 { |
247 { |
321 #if defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE) |
248 #ifdef TRACE_INTO_FILE |
|
249 |
322 FUNC( "CMAIL %S >", &iFunc ); |
250 FUNC( "CMAIL %S >", &iFunc ); |
323 #endif |
251 |
324 #if defined(TRACE_INTO_FILE) && defined(TRACE_FILE_LIMIT_SIZE) |
252 #else//TRACE_INTO_FILE not defined |
325 TBuf8<CMAILLOGBUFFERSIZE> buf(iFunc); |
|
326 buf.Append(_L(">")); |
|
327 CmailLogger::Write( buf ); |
|
328 #endif |
|
329 #if !defined(TRACE_INTO_FILE) |
|
330 |
253 |
331 FUNC( "CMAIL %s >", iFunc.Ptr() ); |
254 FUNC( "CMAIL %s >", iFunc.Ptr() ); |
|
255 |
332 #endif//TRACE_INTO_FILE |
256 #endif//TRACE_INTO_FILE |
333 } |
257 } |
334 TPtrC8 iFunc; |
258 TPtrC8 iFunc; |
335 }; |
259 }; |
336 |
260 |
337 #define FUNC_LOG TFuncLog _fl( __PRETTY_FUNCTION__ ); |
261 #define FUNC_LOG TFuncLog _fl( __PRETTY_FUNCTION__ ); |
|
262 |
338 #else//FUNC_TRACE not defined |
263 #else//FUNC_TRACE not defined |
339 |
264 |
340 #define FUNC_LOG |
265 #define FUNC_LOG |
341 |
266 |
342 #endif//FUNC_TRACE |
267 #endif//FUNC_TRACE |
343 |
268 |
344 //----------------------------------------------------------------------------- |
269 //----------------------------------------------------------------------------- |
345 // Timestamp trace macros |
270 // Timestamp trace macros |
346 //----------------------------------------------------------------------------- |
271 //----------------------------------------------------------------------------- |
347 // |
272 // |
348 #if defined(TIMESTAMP_TRAC) |
273 #ifdef TIMESTAMP_TRACE |
349 |
274 |
350 #if defined(TRACE_INTO_FIL) |
275 #ifdef TRACE_INTO_FILE |
351 |
276 |
352 #define TIMESTAMP( aCaption )\ |
277 #define TIMESTAMP( aCaption )\ |
353 {\ |
278 {\ |
354 TTime t;\ |
279 TTime t;\ |
355 t.HomeTime();\ |
280 t.HomeTime();\ |