|
1 /** |
|
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file Log.h |
|
22 */ |
|
23 |
|
24 #include <f32file.h> |
|
25 |
|
26 #if (!defined __LOG_H__) |
|
27 #define __LOG_H__ |
|
28 |
|
29 /** |
|
30 max length of log file line |
|
31 @internalComponent |
|
32 */ |
|
33 #define MAX_LOG_LINE_LENGTH 256 |
|
34 |
|
35 /** |
|
36 max length of source file name |
|
37 @internalComponent |
|
38 */ |
|
39 #define MAX_LOG_FILENAME_LENGTH 200 |
|
40 |
|
41 /** |
|
42 severity level |
|
43 @internalComponent |
|
44 */ |
|
45 enum TSeverity |
|
46 { |
|
47 ESevrErr = 1, |
|
48 ESevrWarn = 2, |
|
49 ESevrInfo = 4, |
|
50 ESevrAll = 7 |
|
51 }; |
|
52 |
|
53 /** |
|
54 The test result. |
|
55 @internalAll |
|
56 */ |
|
57 enum TVerdict |
|
58 { |
|
59 /** The test has passed. |
|
60 */ |
|
61 EPass =0, |
|
62 |
|
63 /** The test has failed. |
|
64 */ |
|
65 EFail, |
|
66 |
|
67 /** The test system was unable to run the test, due to an error in another part of software. |
|
68 */ |
|
69 EInconclusive, |
|
70 |
|
71 /** The test system was unable to run the test, due to an internal error in the test system. |
|
72 */ |
|
73 ETestSuiteError, |
|
74 |
|
75 /** The test was aborted (possibly by the test operator). |
|
76 */ |
|
77 EAbort |
|
78 }; |
|
79 |
|
80 class TIntegrationTestLog16Overflow :public TDes16Overflow |
|
81 /** |
|
82 Unicode overflow handler |
|
83 @internalComponent |
|
84 */ |
|
85 { |
|
86 public: |
|
87 /** TDes16Overflow pure virtual */ |
|
88 virtual void Overflow(TDes16& aDes); |
|
89 }; |
|
90 |
|
91 class CFileLogger |
|
92 /** |
|
93 File Logger client interface that Controls the flogger server. |
|
94 This class is responsible for providing all functions clients |
|
95 required of the flogger system. |
|
96 This member is internal and not intended for use. |
|
97 @internalComponent |
|
98 */ |
|
99 { |
|
100 public: |
|
101 IMPORT_C void CreateLog(const TDesC& aDir, const TDesC& aName); |
|
102 IMPORT_C TInt Connect( void ); |
|
103 IMPORT_C void CloseLog( void ); |
|
104 IMPORT_C void WriteFormat( TRefByValue<const TDesC16> format, ... ); |
|
105 |
|
106 private: |
|
107 // handle |
|
108 RFile iLogfile; |
|
109 RFs iFs; |
|
110 TBool iEnabled; |
|
111 }; |
|
112 |
|
113 class CLog : public CBase |
|
114 /** |
|
115 Class CLog used for all file and console log data |
|
116 @internalComponent |
|
117 */ |
|
118 { |
|
119 public: |
|
120 IMPORT_C static CLog * NewL(CConsoleBase * console); |
|
121 IMPORT_C void Construct( CConsoleBase * console ); |
|
122 IMPORT_C ~CLog(); |
|
123 |
|
124 /** open close log file */ |
|
125 IMPORT_C void OpenLogFileL(const TFileName &scriptFileName); |
|
126 IMPORT_C void CloseLogFile(); |
|
127 |
|
128 /** write to log output in Printf style */ |
|
129 IMPORT_C void Log( TRefByValue<const TDesC16> format, ... ); |
|
130 |
|
131 /** write to log output in Printf style */ |
|
132 IMPORT_C void Log( TInt aSeverity, TRefByValue<const TDesC16> format, ... ); |
|
133 |
|
134 /** write to log output in Printf style */ |
|
135 IMPORT_C void Log( TRefByValue<const TDesC16> format, VA_LIST aList ); |
|
136 |
|
137 IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity, |
|
138 TRefByValue<const TDesC> aFmt, VA_LIST aList); |
|
139 |
|
140 IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity, |
|
141 TRefByValue<const TDesC> aFmt, ...); |
|
142 |
|
143 IMPORT_C void LogResult( TVerdict ver, TRefByValue<const TDesC16> format, ... ); |
|
144 |
|
145 /** add some blank lins to log output */ |
|
146 IMPORT_C void LogBlankLine( TInt number =1 ); |
|
147 |
|
148 /** convert a EPOC error to text */ |
|
149 IMPORT_C static TPtrC EpocErrorToText(TInt aError); |
|
150 |
|
151 /** convert a test verdict to text */ |
|
152 IMPORT_C const TText* TestResultText( enum TVerdict TestVerdict ); |
|
153 |
|
154 /** get severity */ |
|
155 IMPORT_C void SetSeverity( TInt aSeverity ); |
|
156 |
|
157 /** set severity */ |
|
158 IMPORT_C TInt Severity(); |
|
159 |
|
160 /** set severity */ |
|
161 IMPORT_C void SetPutSrcInfo( TBool aPutSrcInfo ); |
|
162 |
|
163 |
|
164 inline void SetHtmlLogMode(TBool aArg) |
|
165 /** |
|
166 set Html log mode |
|
167 */ |
|
168 { iHtmlLogMode = aArg;}; |
|
169 |
|
170 |
|
171 inline TBool HtmlLogMode( ) |
|
172 /** |
|
173 get Html log mode |
|
174 */ |
|
175 {return iHtmlLogMode;}; |
|
176 |
|
177 protected: |
|
178 /** log systems pointer to the current console */ |
|
179 CConsoleBase * iConsole; |
|
180 |
|
181 /** File logging system */ |
|
182 CFileLogger iFileLogger; |
|
183 |
|
184 /** Severity level */ |
|
185 TInt iSeverity; |
|
186 |
|
187 /** Do we need to put information about source file & #line? |
|
188 Default is yes. */ |
|
189 TBool iPutSrcInfo; |
|
190 |
|
191 /** Do we need to produce HTML log file? |
|
192 Default is yes. */ |
|
193 TBool iHtmlLogMode; |
|
194 }; |
|
195 |
|
196 /** |
|
197 @note To use this macro you have to define in your class |
|
198 method LogExtra(); |
|
199 @internalComponent |
|
200 */ |
|
201 #define INFO_PRINTF1(p1) LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1)) |
|
202 |
|
203 /** |
|
204 @note To use this macro you have to define in your class |
|
205 method LogExtra(); |
|
206 @internalComponent |
|
207 */ |
|
208 #define INFO_PRINTF2(p1, p2) LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2)) |
|
209 |
|
210 /** |
|
211 @note To use this macro you have to define in your class |
|
212 method LogExtra(); |
|
213 @internalComponent |
|
214 */ |
|
215 #define INFO_PRINTF3(p1, p2, p3) LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3)) |
|
216 |
|
217 /** |
|
218 @note To use this macro you have to define in your class |
|
219 method LogExtra(); |
|
220 @internalComponent |
|
221 */ |
|
222 #define INFO_PRINTF4(p1, p2, p3, p4) LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4)) |
|
223 |
|
224 /** |
|
225 @note To use this macro you have to define in your class |
|
226 method LogExtra(); |
|
227 @internalComponent |
|
228 */ |
|
229 #define INFO_PRINTF5(p1, p2, p3, p4, p5) LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5)) |
|
230 |
|
231 /** |
|
232 @note To use this macro you have to define in your class |
|
233 method LogExtra(); |
|
234 @internalComponent |
|
235 */ |
|
236 #define INFO_PRINTF6(p1, p2, p3, p4, p5, p6) LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6)) |
|
237 |
|
238 /** |
|
239 @note To use this macro you have to define in your class |
|
240 method LogExtra(); |
|
241 @internalComponent |
|
242 */ |
|
243 #define INFO_PRINTF7(p1, p2, p3, p4, p5, p6, p7) LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2), (p3), (p4), (p5), (p6), (p7)) |
|
244 |
|
245 /** |
|
246 @note To use this macro you have to define in your class |
|
247 method LogExtra(); |
|
248 @internalComponent |
|
249 */ |
|
250 #define WARN_PRINTF1(p1) LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1)) |
|
251 |
|
252 /** |
|
253 @note To use this macro you have to define in your class |
|
254 method LogExtra(); |
|
255 @internalComponent |
|
256 */ |
|
257 #define WARN_PRINTF2(p1, p2) LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2)) |
|
258 |
|
259 /** |
|
260 @note To use this macro you have to define in your class |
|
261 method LogExtra(); |
|
262 @internalComponent |
|
263 */ |
|
264 #define WARN_PRINTF3(p1, p2, p3) LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3)) |
|
265 |
|
266 /** |
|
267 @note To use this macro you have to define in your class |
|
268 method LogExtra(); |
|
269 @internalComponent |
|
270 */ |
|
271 #define WARN_PRINTF4(p1, p2, p3, p4) LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4)) |
|
272 |
|
273 /** |
|
274 @note To use this macro you have to define in your class |
|
275 method LogExtra(); |
|
276 @internalComponent |
|
277 */ |
|
278 #define WARN_PRINTF5(p1, p2, p3, p4, p5) LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5)) |
|
279 |
|
280 /** |
|
281 @note To use this macro you have to define in your class |
|
282 method LogExtra(); |
|
283 @internalComponent |
|
284 */ |
|
285 #define WARN_PRINTF6(p1, p2, p3, p4, p5, p6) LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6)) |
|
286 |
|
287 /** |
|
288 @note To use this macro you have to define in your class |
|
289 method LogExtra(); |
|
290 @internalComponent |
|
291 */ |
|
292 #define WARN_PRINTF7(p1, p2, p3, p4, p5, p6, p7) LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, (p1), (p2), (p3), (p4), (p5), (p6), (p7)) |
|
293 |
|
294 |
|
295 /** |
|
296 @note To use this macro you have to define in your class |
|
297 method LogExtra(); |
|
298 @internalComponent |
|
299 */ |
|
300 #define ERR_PRINTF1(p1) LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1)) |
|
301 |
|
302 /** |
|
303 @note To use this macro you have to define in your class |
|
304 method LogExtra(); |
|
305 @internalComponent |
|
306 */ |
|
307 #define ERR_PRINTF2(p1, p2) LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)) |
|
308 |
|
309 /** |
|
310 @note To use this macro you have to define in your class |
|
311 method LogExtra(); |
|
312 @internalComponent |
|
313 */ |
|
314 #define ERR_PRINTF3(p1, p2, p3) LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)) ; |
|
315 |
|
316 /** |
|
317 @note To use this macro you have to define in your class |
|
318 method LogExtra(); |
|
319 @internalComponent |
|
320 */ |
|
321 #define ERR_PRINTF4(p1, p2, p3, p4) LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4)) |
|
322 |
|
323 /** |
|
324 @note To use this macro you have to define in your class |
|
325 method LogExtra(); |
|
326 @internalComponent |
|
327 */ |
|
328 #define ERR_PRINTF5(p1, p2, p3, p4, p5) LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5)) |
|
329 |
|
330 /** |
|
331 @note To use this macro you have to define in your class |
|
332 method LogExtra(); |
|
333 @internalComponent |
|
334 */ |
|
335 #define ERR_PRINTF6(p1, p2, p3, p4, p5, p6) LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6)) |
|
336 |
|
337 /** |
|
338 @note To use this macro you have to define in your class |
|
339 method LogExtra(); |
|
340 @internalComponent |
|
341 */ |
|
342 #define ERR_PRINTF7(p1, p2, p3, p4, p5, p6, p7) LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3), (p4), (p5), (p6), (p7)) |
|
343 |
|
344 |
|
345 /** |
|
346 @note To use this macro you have to define in your class |
|
347 method LogExtra(); |
|
348 @internalComponent |
|
349 */ |
|
350 #define TEST_START(p1) LogExtra((TText8*)__FILE__, __LINE__, ESevrInfo, (_L("======Start test %S")), (p1)) |
|
351 |
|
352 /** |
|
353 @note To use this macro you have to define in your class |
|
354 method LogExtra(); |
|
355 @internalComponent |
|
356 */ |
|
357 #define TEST_NEXT(p1) LogExtra((TText8*)__FILE__, __LINE__, ESevrInfo, _L("Next test %S"), (p1)) |
|
358 |
|
359 /** |
|
360 @note To use this macro you have to define in your class |
|
361 method LogExtra(); |
|
362 @internalComponent |
|
363 */ |
|
364 #define TEST_END() LogExtra((TText8*)__FILE__, __LINE__, ESevrInfo, _L("======End test =====") ) |
|
365 |
|
366 #endif /* __LOG_H__ */ |