1 /* |
|
2 * Copyright (c) 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: This file contains the header file of the |
|
15 * CStifLogger. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef STIFLOGGER_H |
|
20 #define STIFLOGGER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 // If using older STIF TF than STIF200414 there is no this definition. |
|
26 // If is need to combile e.g. testmodule with older STIF TF there may use |
|
27 // in the testmodule this flag to indicating which enum definition is used. |
|
28 // Example: |
|
29 // #ifdef __NEW_LOGGER_ENUMS_DEFS__ |
|
30 // logger->Log( CStifLogger::ERed, _L( "Logged text" ) ); |
|
31 // #else |
|
32 // logger->Log( ERed, _L( "Logged text" ) ); |
|
33 // #endif |
|
34 #define __NEW_LOGGER_ENUMS_DEFS__ |
|
35 |
|
36 // Maximum length of the data. Must be over 26 because HTML page initializing. |
|
37 // Can be only max 254 length because rdebug prints max 256 length text and |
|
38 // that includes line break(+2 character) |
|
39 const TInt KMaxLogData = 254; |
|
40 |
|
41 // This is for making partitions of the rdebug( minus 3 is for ' ->') |
|
42 const TInt KMaxRDebug = KMaxLogData - 3; |
|
43 |
|
44 // Maximum count of file type plus dot e.g. ".txt" |
|
45 const TInt KMaxFileType = 10; |
|
46 |
|
47 // Maximum length of the date and time logging |
|
48 // Includes date, time, spaces(5) and end of line(2): |
|
49 // e.g. "'06.Nov.2003 15:12:18.123 '...logged data...' '" |
|
50 const TInt KMaxTimeStamp = 30; |
|
51 |
|
52 // MACROS |
|
53 // None |
|
54 |
|
55 // DATA TYPES |
|
56 |
|
57 // For 16 bit data size definition. |
|
58 typedef TBuf<KMaxLogData> TLogInfo; |
|
59 |
|
60 // For 8 bit data size definition. |
|
61 typedef TBuf8<KMaxLogData> TLogInfo8; |
|
62 |
|
63 // For file type size definition. |
|
64 typedef TBuf<KMaxFileType> TFileType; |
|
65 |
|
66 // For time stamp size definition. |
|
67 typedef TBuf8<KMaxTimeStamp> TStifLoggerTimeStamp; |
|
68 |
|
69 // For time stamp size definition. |
|
70 typedef TBuf<KMaxTimeStamp> TStifLoggerTimeStamp8; |
|
71 |
|
72 // FUNCTION PROTOTYPES |
|
73 // None |
|
74 |
|
75 // FORWARD DECLARATIONS |
|
76 class COutput; |
|
77 |
|
78 // Structs are defined at the end of this file. |
|
79 struct TOverwritedSettings; |
|
80 struct TLoggerSettings; |
|
81 |
|
82 // CLASS DECLARATION |
|
83 |
|
84 // DESCRIPTION |
|
85 // CStifLogger is a STIF Test Framework StifLogger class. |
|
86 // Class contains a file logging operations. |
|
87 |
|
88 class CStifLogger |
|
89 :public CBase |
|
90 { |
|
91 public: // Enumerations |
|
92 |
|
93 // Different StifLogger presentations types. |
|
94 enum TLoggerType |
|
95 { |
|
96 ETxt, // txt file logging |
|
97 EData, // data file logging(e.g. web page downloading ) |
|
98 EHtml // html file logging |
|
99 }; |
|
100 |
|
101 // Different StifLogger output modules. |
|
102 enum TOutput |
|
103 { |
|
104 EFile, // File logging |
|
105 ERDebug // RDebug logging |
|
106 }; |
|
107 |
|
108 // Different style forms for text. |
|
109 enum TStyle |
|
110 { |
|
111 ENoStyle = 0x00000, // No style parameter |
|
112 EBold = 0x00001, // Bold |
|
113 ECursive = 0x00002, // Cursive |
|
114 EUnderline = 0x00004, // Underline |
|
115 EBlue = 0x00008, // Blue |
|
116 EGreen = 0x00010, // Green |
|
117 ERed = 0x00020, // Red |
|
118 EImportant = 0x00040, // Important (Line will starts a 'IMPORTANT' text) |
|
119 EWarning = 0x00080, // Warning (Line will starts a 'WARNING' text) |
|
120 EError = 0x00100 // Error (Line will starts a 'ERROR' text) |
|
121 }; |
|
122 |
|
123 private: // Enumerations |
|
124 |
|
125 public: // Constructors and destructor |
|
126 |
|
127 /** |
|
128 * Two-phased constructor. |
|
129 */ |
|
130 IMPORT_C static CStifLogger* NewL( const TDesC& aTestPath, |
|
131 const TDesC& aTestFile, |
|
132 // Default logger type is .txt |
|
133 TLoggerType aLoggerType = ETxt, |
|
134 // By default output is file |
|
135 TOutput aOutput = EFile, |
|
136 // By default overwrite is used |
|
137 TBool aOverWrite = ETrue, |
|
138 // By default time stamp is used |
|
139 TBool aWithTimeStamp = ETrue, |
|
140 // By default line break is used |
|
141 TBool aWithLineBreak = ETrue, |
|
142 // By default even ranking is not |
|
143 // used |
|
144 TBool aWithEventRanking = EFalse, |
|
145 // By default thread id is added |
|
146 // after the log file |
|
147 TBool aThreadIdToLogFile = ETrue, |
|
148 // By default log directory will |
|
149 // not create |
|
150 TBool aCreateLogDir = EFalse, |
|
151 // Static logger implementation is |
|
152 // not yet permanent, may change |
|
153 TInt aStaticBufferSize = 0, |
|
154 // By default files are not written |
|
155 // in unicode format |
|
156 TBool aUnicode = EFalse ); |
|
157 /** |
|
158 * Destructor. |
|
159 */ |
|
160 virtual ~CStifLogger(); |
|
161 |
|
162 public: // New functions |
|
163 |
|
164 /** |
|
165 * C++ default constructor. |
|
166 */ |
|
167 CStifLogger(); |
|
168 |
|
169 /** |
|
170 * Log a 16 bit information to some storage e.g. text file. |
|
171 */ |
|
172 IMPORT_C TInt Log( const TDesC& aLogInfo ); |
|
173 |
|
174 /** |
|
175 * Log a 8 bit information to some storage e.g. text file. |
|
176 */ |
|
177 IMPORT_C TInt Log( const TDesC8& aLogInfo ); |
|
178 |
|
179 /** |
|
180 * Log a 16 bit information to some storage e.g. text file. There is |
|
181 * also parameter to styling text information e.g. text color. |
|
182 */ |
|
183 IMPORT_C TInt Log( TInt aStyle, const TDesC& aLogInfo ); |
|
184 |
|
185 /** |
|
186 * Log a 8 bit information to some storage e.g. text file. There is |
|
187 * also parameter to styling text information e.g. text color. |
|
188 */ |
|
189 IMPORT_C TInt Log( TInt aStyle, const TDesC8& aLogInfo ); |
|
190 |
|
191 /** |
|
192 * Log a 16 bit information to some storage e.g. text file. In this log |
|
193 * method may set several parameters. |
|
194 */ |
|
195 IMPORT_C TInt Log( TRefByValue<const TDesC> aLogInfo,... ); |
|
196 |
|
197 /** |
|
198 * Log a 8 bit information to some storage e.g. text file. In this log |
|
199 * method may set several parameters. |
|
200 */ |
|
201 IMPORT_C TInt Log( TRefByValue<const TDesC8> aLogInfo,... ); |
|
202 |
|
203 /** |
|
204 * Log a 16 bit information to some storage e.g. text file. There is |
|
205 * also parameter to styling text information e.g. text color. |
|
206 */ |
|
207 IMPORT_C TInt Log( TInt aStyle, |
|
208 TRefByValue<const TDesC> aLogInfo,... ); |
|
209 |
|
210 /** |
|
211 * Log a 8 bit information to some storage e.g. text file. There is |
|
212 * also parameter to styling text information e.g. text color. |
|
213 */ |
|
214 IMPORT_C TInt Log( TInt aStyle, |
|
215 TRefByValue<const TDesC8> aLogInfo,... ); |
|
216 |
|
217 /** |
|
218 * Log a 16 bit delimiter. Default char is '#' and default |
|
219 * repeat count is 60. |
|
220 * This will be used if parameters are not given when calling |
|
221 * this method. |
|
222 */ |
|
223 IMPORT_C TInt WriteDelimiter( const TDesC& aDelimiter = _L( "#"), |
|
224 TInt aCount = 60 ); |
|
225 |
|
226 /** |
|
227 * Log a 8 bit delimiter. 8 bit delimiter includes no default values. |
|
228 * Delimiter may be '#' or 'XO' etc. |
|
229 */ |
|
230 IMPORT_C TInt WriteDelimiter( const TDesC8& aDelimiter, TInt aCount ); |
|
231 |
|
232 /** |
|
233 * Used when is need to save file or data to storage e.g. web page. |
|
234 * 16 bit. |
|
235 */ |
|
236 IMPORT_C TInt SaveData( TDesC& aData ); |
|
237 |
|
238 /** |
|
239 * Used when is need to save file or data to storage e.g. web page. |
|
240 * 8 bit. |
|
241 */ |
|
242 IMPORT_C TInt SaveData( TDesC8& aData ); |
|
243 |
|
244 /** |
|
245 * Get creation result. |
|
246 */ |
|
247 IMPORT_C TInt CreationResult(); |
|
248 |
|
249 /** |
|
250 * Get output type. Valid only if CreationResult returns KErrNone. |
|
251 */ |
|
252 IMPORT_C TOutput OutputType(); |
|
253 |
|
254 /** |
|
255 * Pure virtual. Send style information and data to the output module. |
|
256 * 16 bit. |
|
257 */ |
|
258 virtual TInt Send( TInt /*aStyle*/, const TDesC& /*aData*/ ) = 0; |
|
259 |
|
260 /** |
|
261 * Pure virtual. Send style information and data to the output module. |
|
262 * 8 bit. |
|
263 */ |
|
264 virtual TInt Send( TInt /*aStyle*/, const TDesC8& /*aData*/ ) = 0; |
|
265 |
|
266 /** |
|
267 * Log 16 bit _LIT information to some storage e.g. text file. |
|
268 */ |
|
269 template<TInt S> TInt Log( const TLitC<S>& aLogInfo ) |
|
270 { |
|
271 return Send( ENoStyle, (TDesC&)aLogInfo ); |
|
272 }; |
|
273 |
|
274 /** |
|
275 * Log 8 bit _LIT information to some storage e.g. text file. |
|
276 */ |
|
277 template<TInt S> TInt Log( const TLitC8<S>& aLogInfo ) |
|
278 { |
|
279 return Send( ENoStyle, (TDesC8&)aLogInfo ); |
|
280 }; |
|
281 |
|
282 /** |
|
283 * Log 16 bit _LIT information to some storage e.g. text file. There is |
|
284 * also parameter to styling text information e.g. text color. |
|
285 */ |
|
286 template<TInt S> TInt Log( TInt aStyle, const TLitC<S>& aLogInfo ) |
|
287 { |
|
288 return Send( aStyle, (TDesC&)aLogInfo ); |
|
289 }; |
|
290 |
|
291 /** |
|
292 * Log 8 bit _LIT information to some storage e.g. text file. There is |
|
293 * also parameter to styling text information e.g. text color. |
|
294 */ |
|
295 template<TInt S> TInt Log( TInt aStyle, const TLitC8<S>& aLogInfo ) |
|
296 { |
|
297 return Send( aStyle, (TDesC8&)aLogInfo ); |
|
298 }; |
|
299 |
|
300 public: // Functions from base classes |
|
301 |
|
302 protected: // New functions |
|
303 |
|
304 /** |
|
305 * Two-phased constructor. TestEngine's and TestServer's are friend. |
|
306 * For TestEngine's and TestServer's StifLogger creation. |
|
307 */ |
|
308 IMPORT_C static CStifLogger* NewL( const TDesC& aTestPath, |
|
309 const TDesC& aTestFile, |
|
310 TLoggerSettings& aLoggerSettings ); |
|
311 |
|
312 protected: // Functions from base classes |
|
313 |
|
314 /** |
|
315 * Local CStifLogger's method for StifLogger settings overwriting. |
|
316 */ |
|
317 static void OverwriteLoggerSettings( TLoggerSettings& aLoggerSettings, |
|
318 TName& aTestPath, |
|
319 TName& aTestFile, |
|
320 TLoggerType& aLoggerType, |
|
321 TOutput& aOutput, |
|
322 TBool& aOverWrite, |
|
323 TBool& aWithTimeStamp, |
|
324 TBool& aWithLineBreak, |
|
325 TBool& aWithEventRanking, |
|
326 TBool& aThreadIdToLogFile, |
|
327 TBool& aCreateLogDir, |
|
328 TBool& aUnicode ); |
|
329 |
|
330 private: |
|
331 |
|
332 public: // Data |
|
333 |
|
334 protected: // Data |
|
335 /** |
|
336 * Output object. |
|
337 */ |
|
338 COutput* iOutput; |
|
339 |
|
340 private: // Data |
|
341 |
|
342 public: // Friend classes |
|
343 |
|
344 protected: // Friend classes |
|
345 |
|
346 private: // Friend classes |
|
347 |
|
348 // TestEngine classes |
|
349 friend class CTestEngineServer; |
|
350 friend class CTestReport; |
|
351 friend class CTestCaseController; |
|
352 friend class CTestEngine; |
|
353 |
|
354 // TestServer classes |
|
355 friend class CTestModuleContainer; |
|
356 friend class CTestServer; |
|
357 friend class CTestThreadContainer; |
|
358 friend class CTestThreadContainerRunner; |
|
359 |
|
360 // UIEngine classes |
|
361 friend class CUIEngine; |
|
362 |
|
363 // SettingServer classes |
|
364 friend class CSettingServer; |
|
365 |
|
366 }; |
|
367 |
|
368 // Struct to indicate StifLogger's settings overwriting |
|
369 struct TOverwritedSettings |
|
370 { |
|
371 TBool iCreateLogDir; |
|
372 TBool iPath; |
|
373 TBool iHwPath; |
|
374 TBool iFormat; |
|
375 TBool iHwFormat; |
|
376 TBool iOutput; |
|
377 TBool iHwOutput; |
|
378 TBool iOverwrite; |
|
379 TBool iTimeStamp; |
|
380 TBool iLineBreak; |
|
381 TBool iEventRanking; |
|
382 TBool iThreadId; |
|
383 TBool iUnicode; |
|
384 TBool iAddTestCaseTitle; |
|
385 }; |
|
386 |
|
387 // Struct to StifLogger overwrite settings |
|
388 struct TLoggerSettings |
|
389 { |
|
390 TBool iCreateLogDirectories; |
|
391 TName iEmulatorPath; |
|
392 CStifLogger::TLoggerType iEmulatorFormat; |
|
393 CStifLogger::TOutput iEmulatorOutput; |
|
394 TName iHardwarePath; |
|
395 CStifLogger::TLoggerType iHardwareFormat; |
|
396 CStifLogger::TOutput iHardwareOutput; |
|
397 TBool iOverwrite; |
|
398 TBool iTimeStamp; |
|
399 TBool iLineBreak; |
|
400 TBool iEventRanking; |
|
401 TBool iThreadId; |
|
402 TBool iUnicode; |
|
403 TBool iAddTestCaseTitle; |
|
404 TOverwritedSettings iIsDefined; |
|
405 }; |
|
406 |
|
407 #endif // STIFLOGGER_H |
|
408 |
|
409 // End of File |
|