|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Comms Debug Utility (File and Serial logger) Client side header |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 #ifndef __COMMSDEBUGUTILITY_H__ |
|
24 #define __COMMSDEBUGUTILITY_H__ |
|
25 |
|
26 #ifndef __FLOG_NO_UDEB |
|
27 #ifdef _DEBUG |
|
28 #ifndef __FLOG_ACTIVE |
|
29 #define __FLOG_ACTIVE |
|
30 #endif |
|
31 #endif // _DEBUG |
|
32 #endif //__FLOG_NO_UDEB |
|
33 |
|
34 #ifdef __FLOG_UREL |
|
35 #ifndef _DEBUG |
|
36 #ifndef __FLOG_ACTIVE |
|
37 #define __FLOG_ACTIVE |
|
38 #endif //__FLOG_ACTIVE |
|
39 #endif //_DEBUG |
|
40 #endif //__FLOG_UREL |
|
41 |
|
42 |
|
43 #define __FLOG_DECLARATION_MEMBER_SIZE TInt32 |
|
44 |
|
45 |
|
46 // constants available to clients in either build so they can be used in classes |
|
47 #include <e32base.h> |
|
48 |
|
49 const TInt KLogBufferSize=200; ///< Any attempt to write logs longer than KLogBufferSize and the client string will be truncated. |
|
50 const TInt KMaxHexDumpWidth = 150; ///< If the client asks to hexdump a string longer than this, the string will be truncated |
|
51 const TInt KMaxTagLength = 16; ///< Maximum length of the client tag strings. Exceeding this causes the tag to be truncated. |
|
52 |
|
53 |
|
54 #if defined __FLOG_ACTIVE |
|
55 |
|
56 // make sure clients using this in release mode get a warning. |
|
57 #if (!defined __FLOG_SUPPRESS_REL_WARNING) && (!defined _DEBUG) |
|
58 #pragma message ("WARNING: Use of comms-infras/CommsDebugUtility.h in active mode in a release build") |
|
59 #endif |
|
60 |
|
61 |
|
62 const TInt KMaxMediaSettingLength = 0x20; ///< Maximum expected length for media setting tag |
|
63 |
|
64 |
|
65 _LIT(KFloggerPanic, "Comsdbgutil.dll"); ///< The text which defines any flogger panic. Sent to User::Panic. |
|
66 |
|
67 /** |
|
68 * Panic codes |
|
69 * |
|
70 * @internalTechnology |
|
71 * @note The order of the panic numbers should not be changed. |
|
72 * New panic codes must be added at the end of this enum. |
|
73 * All panic codes are assigned to values to ease debugging. |
|
74 */ |
|
75 enum TFloggerPanics |
|
76 { |
|
77 ESetLogTagsNotCalled = 0, ///< Attempt by client to write without first setting the ID tags |
|
78 EInternalConsistencyFault = 1 ///< A situation has arisen which indicates a programming fault in flogger since the situation should not be caused by any external inputs |
|
79 }; |
|
80 |
|
81 /** |
|
82 * Logging Mode codes |
|
83 * |
|
84 * @internalTechnology |
|
85 * @deprecated As of version 8.0 the logging modes are deprecated due to the introduction |
|
86 * of a single log file. Appent mode is the default for all write operations, |
|
87 * while Overwrite can be achieved using new __FLOG_CLEAR macro, or ClearLog API. |
|
88 */ |
|
89 enum TFileLoggingMode |
|
90 { |
|
91 EFileLoggingModeUnknown =0, ///< Deprecated - has no effect |
|
92 EFileLoggingModeAppend, ///< Deprecated - has no effect |
|
93 EFileLoggingModeOverwrite, ///< Deprecated - has no effect |
|
94 EFileLoggingModeAppendRaw, ///< Deprecated - has no effect |
|
95 EFileLoggingModeOverwriteRaw ///< Deprecated - has no effect |
|
96 }; |
|
97 |
|
98 class RFileLoggerBody; |
|
99 |
|
100 |
|
101 /** |
|
102 * Flogger - File and Serial Logger client interface |
|
103 * |
|
104 * @internalTechnology |
|
105 * This class is responsible for providing all functions |
|
106 * clients require of the flogger system. It is preferred, though, |
|
107 * that clients use the provided macros which refer to these API's |
|
108 * so that all logging code is governed by the global __FLOG_ACTIVE |
|
109 * macro setting. The macro's are not currently documented using |
|
110 * doxygen - you will need to consult the flogger user guide instead. |
|
111 * RFileLogger is the only exported interface for the flogger component. |
|
112 */ |
|
113 class RFileLogger |
|
114 { |
|
115 public: |
|
116 IMPORT_C RFileLogger(); |
|
117 IMPORT_C ~RFileLogger(); |
|
118 IMPORT_C TVersion Version() const; |
|
119 IMPORT_C TInt Connect(); |
|
120 IMPORT_C void SetDateAndTime(TBool aUseDate,TBool aUseTime); //Deprecated. Does nothing. |
|
121 IMPORT_C void CreateLog(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/); //Deprecated. Use SetLogTags instead. |
|
122 IMPORT_C void CloseLog(); //Deprecated. |
|
123 |
|
124 IMPORT_C static void Write(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, const TDesC16& aText); // Removed |
|
125 IMPORT_C static void WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode aMode, TRefByValue<const TDesC16> aFmt,...); // Removed |
|
126 IMPORT_C static void WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, TRefByValue<const TDesC16> aFmt, VA_LIST& aList); // Removed |
|
127 IMPORT_C static void Write(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, const TDesC8& aText); // Removed |
|
128 IMPORT_C static void WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode aMode, TRefByValue<const TDesC8> aFmt,...); // Removed |
|
129 IMPORT_C static void WriteFormat(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, TRefByValue<const TDesC8> aFmt, VA_LIST& aList); // Removed |
|
130 IMPORT_C static void HexDump(const TDesC& aSubsystem, const TDesC& aComponent, TFileLoggingMode /*aMode*/, const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen); // Removed |
|
131 |
|
132 IMPORT_C static void Write(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC16& aText); |
|
133 IMPORT_C static void WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC16> aFmt,...); |
|
134 IMPORT_C static void WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC16> aFmt, VA_LIST& aList); |
|
135 IMPORT_C static void Write(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aText); |
|
136 IMPORT_C static void WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC8> aFmt,...); |
|
137 IMPORT_C static void WriteFormat(const TDesC8& aSubsystem, const TDesC8& aComponent, const TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
138 IMPORT_C static void HexDump(const TDesC8& aSubsystem, const TDesC8& aComponent, const TDesC8& aData, const TDesC8& aHeader = TPtrC8(NULL,0)); |
|
139 |
|
140 IMPORT_C void Write(const TDesC16& aText); |
|
141 IMPORT_C void WriteFormat(TRefByValue<const TDesC16> aFmt,...); |
|
142 IMPORT_C void WriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList); |
|
143 IMPORT_C void Write(const TDesC8& aText); |
|
144 IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt,...); |
|
145 IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
146 IMPORT_C void WriteBinary(const TDesC8& aData); |
|
147 IMPORT_C void HexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen); |
|
148 IMPORT_C void HexDump(const TDesC8& aData, const TDesC8& aHeader = TPtrC8(NULL,0)); |
|
149 |
|
150 IMPORT_C TInt LastError() const; //Deprecated. |
|
151 IMPORT_C TBool LogValid() const; //Deprecated. |
|
152 IMPORT_C void Close(); |
|
153 IMPORT_C TInt ClearLog(); |
|
154 IMPORT_C TInt SetLogTags(const TDesC8& aSubsystem, const TDesC8& aComponent); |
|
155 IMPORT_C TInt Handle() const; |
|
156 IMPORT_C TInt Share(); |
|
157 IMPORT_C void __DbgShutDownServer(); //For testing purposes only |
|
158 IMPORT_C void __DbgSetHeapFailure(TInt aFailAfter); |
|
159 private: |
|
160 TInt DoConnect(); |
|
161 TInt DoSetLogTags(const TDesC8& aSubsystem, const TDesC8& aComponent); |
|
162 void DoWrite(const TDesC8& aBuf); |
|
163 void DoWriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList); |
|
164 void DoWriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
165 void DoSendStaticWrite(const TDesC8& aDir, const TDesC8& aName, const TDesC8& aBuf); |
|
166 static void DoStaticWrite(const TDesC8& aDir, const TDesC8& aName, const TDesC8& aBuf); |
|
167 static void DoStaticWriteFormat(const TDesC8& aDir, const TDesC8& aName, const TRefByValue<const TDesC16> aFmt, VA_LIST& aList); |
|
168 static void DoStaticWriteFormat(const TDesC8& aDir, const TDesC8& aName, const TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
169 void DoHexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen); |
|
170 void DoHexDump(const TDesC8& aData, const TDesC8& aHeader, const TDesC8& aMargin); |
|
171 TBool IsLogging(); |
|
172 RFileLogger& operator=(const RFileLogger& aLogger); //Outlaw copying RFileLogger objects. |
|
173 RFileLogger(const RFileLogger& aLogger); //Outlaw copy constructor |
|
174 private: |
|
175 RFileLoggerBody* iLoggerBody; ///< Reference to all the data the client interface requires. This keeps the class size small and less likely to change in size. |
|
176 }; |
|
177 |
|
178 |
|
179 // Consult the How-to/User Guide for how to use these macros |
|
180 |
|
181 // Sundry Logging Macros |
|
182 |
|
183 #define __FLOG_DECLARATION_MEMBER_MUTABLE mutable RFileLogger __logger__ |
|
184 |
|
185 #define __FLOG_DECLARATION_MEMBER RFileLogger __logger__ |
|
186 |
|
187 #define __FLOG_DECLARATION_VARIABLE RFileLogger __logger__ |
|
188 |
|
189 #define __FLOG_OPEN(subsys,compnt) __logger__.Connect();\ |
|
190 __logger__.SetLogTags(subsys,compnt) |
|
191 |
|
192 #define __FLOG_OPENC(subsys,compnt) __logger__.Connect();\ |
|
193 __logger__.SetLogTags(subsys,compnt);\ |
|
194 CleanupClosePushL(__logger__) |
|
195 |
|
196 #define __FLOG_CLOSE __logger__.Close() |
|
197 |
|
198 #define __FLOG_CLOSE_CLEANUP CleanupStack::PopAndDestroy(&__logger__) |
|
199 |
|
200 #define __FLOG_CLEAR __logger__.ClearLog() |
|
201 |
|
202 #define __FLOG_SET_TAGS(subsys,compnt) __logger__.SetLogTags(subsys,compnt) |
|
203 |
|
204 #define __FLOG_STMT(text) text |
|
205 |
|
206 // Connected Output Logging Macros |
|
207 |
|
208 #define __FLOG_0(text) __logger__.Write(text) |
|
209 |
|
210 #define __FLOG_1(text,a) __logger__.WriteFormat(text,a) |
|
211 |
|
212 #define __FLOG_2(text,a,b) __logger__.WriteFormat(text,a,b) |
|
213 |
|
214 #define __FLOG_3(text,a,b,c) __logger__.WriteFormat(text,a,b,c) |
|
215 |
|
216 #define __FLOG_4(text,a,b,c,d) __logger__.WriteFormat(text,a,b,c,d) |
|
217 |
|
218 #define __FLOG_5(text,a,b,c,d,e) __logger__.WriteFormat(text,a,b,c,d,e) |
|
219 |
|
220 #define __FLOG_6(text,a,b,c,d,e,f) __logger__.WriteFormat(text,a,b,c,d,e,f) |
|
221 |
|
222 #define __FLOG_7(text,a,b,c,d,e,f,g) __logger__.WriteFormat(text,a,b,c,d,e,f,g) |
|
223 |
|
224 #define __FLOG_8(text,a,b,c,d,e,f,g,h) __logger__.WriteFormat(text,a,b,c,d,e,f,g,h) |
|
225 |
|
226 #define __FLOG_9(text,a,b,c,d,e,f,g,h,i) __logger__.WriteFormat(text,a,b,c,d,e,f,g,h,i) |
|
227 |
|
228 #define __FLOG(text) __logger__.Write(text) |
|
229 |
|
230 #define __FLOG_VA(args) __logger__.WriteFormat args |
|
231 |
|
232 #define __FLOG_HEXDUMP(args) __logger__.HexDump args |
|
233 |
|
234 #define __FLOG_BINARY(data) __logger__.WriteBinary(data) |
|
235 |
|
236 // Static Output Logging Macros |
|
237 #define __FLOG_STATIC0(subsys,compnt,text) RFileLogger::Write(subsys,compnt, text) |
|
238 |
|
239 #define __FLOG_STATIC1(subsys,compnt,text,a) RFileLogger::WriteFormat(subsys,compnt, text,a) |
|
240 |
|
241 #define __FLOG_STATIC2(subsys,compnt,text,a,b) RFileLogger::WriteFormat(subsys,compnt, text,a,b) |
|
242 |
|
243 #define __FLOG_STATIC3(subsys,compnt,text,a,b,c) RFileLogger::WriteFormat(subsys,compnt, text,a,b,c) |
|
244 |
|
245 #define __FLOG_STATIC4(subsys,compnt,text,a,b,c,d) RFileLogger::WriteFormat(subsys,compnt, text,a,b,c,d) |
|
246 |
|
247 #define __FLOG_STATIC5(subsys,compnt,text,a,b,c,d,e) RFileLogger::WriteFormat(subsys,compnt, text,a,b,c,d,e) |
|
248 |
|
249 #define __FLOG_STATIC6(subsys,compnt,text,a,b,c,d,e,f) RFileLogger::WriteFormat(subsys,compnt, text,a,b,c,d,e,f) |
|
250 |
|
251 #define __FLOG_STATIC7(subsys,compnt,text,a,b,c,d,e,f,g) RFileLogger::WriteFormat(subsys,compnt, text,a,b,c,d,e,f,g) |
|
252 |
|
253 #define __FLOG_STATIC8(subsys,compnt,text,a,b,c,d,e,f,g,h) RFileLogger::WriteFormat(subsys,compnt, text,a,b,c,d,e,f,g,h) |
|
254 |
|
255 #define __FLOG_STATIC9(subsys,compnt,text,a,b,c,d,e,f,g,h,i) RFileLogger::WriteFormat(subsys,compnt, text,a,b,c,d,e,f,g,h,i) |
|
256 |
|
257 #define __FLOG_STATIC(subsys,compnt,text) RFileLogger::WriteFormat(subsys,compnt, text) |
|
258 |
|
259 #define __FLOG_STATIC_VA(args) RFileLogger::WriteFormat args |
|
260 |
|
261 #define __FLOG_STATIC_HEXDUMP(args) RFileLogger::HexDump args |
|
262 |
|
263 |
|
264 |
|
265 // Line below is used to check that RFileLogger stays the same size as |
|
266 // __FLOG_DECLARATION_MEMBER_SIZE. If the RFileLogger object ever changes size, |
|
267 // the line below will cause the compiler to throw an error. __FLOG_DECLARATION_MEMBER_SIZE |
|
268 // should then be changed accordingly. |
|
269 const TInt KCheckRFileLoggerIsCorrectSize = 1/(sizeof(RFileLogger)==sizeof(__FLOG_DECLARATION_MEMBER_SIZE)); |
|
270 |
|
271 |
|
272 |
|
273 #else |
|
274 // Begin declarations for when Flogger is NOT to be used. |
|
275 // This declares all macros to be void and the class to be replaced with a stub. |
|
276 // This will result in Flogger only requiring 32 bits for each component which uses it. |
|
277 |
|
278 // Consult the How-to/User Guide for how to use these macros |
|
279 |
|
280 // Sundry Logging Macros |
|
281 |
|
282 #define __FLOG_DECLARATION_MEMBER_MUTABLE __FLOG_DECLARATION_MEMBER_SIZE __noLogger__; \ |
|
283 inline void useNoLogger() { __noLogger__ = 0; } |
|
284 |
|
285 #define __FLOG_DECLARATION_MEMBER __FLOG_DECLARATION_MEMBER_SIZE __noLogger__; \ |
|
286 inline void useNoLogger() { __noLogger__ = 0; } |
|
287 |
|
288 #define __FLOG_DECLARATION_VARIABLE |
|
289 |
|
290 #define __FLOG_OPEN(subsys,compnt) |
|
291 |
|
292 #define __FLOG_OPENC(subsys,compnt) |
|
293 |
|
294 #define __FLOG_CLOSE |
|
295 |
|
296 #define __FLOG_CLOSE_CLEANUP |
|
297 |
|
298 #define __FLOG_HEXDUMP(args) |
|
299 |
|
300 #define __FLOG_CLEAR |
|
301 |
|
302 #define __FLOG_SET_TAGS(subsys,compnt) |
|
303 |
|
304 |
|
305 #define __FLOG_STMT(text) |
|
306 |
|
307 |
|
308 // Connected Output Logging Macros |
|
309 |
|
310 #define __FLOG_0(text) |
|
311 |
|
312 #define __FLOG_1(text,a) |
|
313 |
|
314 #define __FLOG_2(text,a,b) |
|
315 |
|
316 #define __FLOG_3(text,a,b,c) |
|
317 |
|
318 #define __FLOG_4(text,a,b,c,d) |
|
319 |
|
320 #define __FLOG_5(text,a,b,c,d,e) |
|
321 |
|
322 #define __FLOG_6(text,a,b,c,d,e,f) |
|
323 |
|
324 #define __FLOG_7(text,a,b,c,d,e,f,g) |
|
325 |
|
326 #define __FLOG_8(text,a,b,c,d,e,f,g,h) |
|
327 |
|
328 #define __FLOG_9(text,a,b,c,d,e,f,g,h,i) |
|
329 |
|
330 #define __FLOG(text) |
|
331 |
|
332 #define __FLOG_VA(args) |
|
333 |
|
334 #define __FLOG_BINARY(data) |
|
335 |
|
336 // Static Output Logging Macros |
|
337 #define __FLOG_STATIC0(subsys,compnt,text) |
|
338 |
|
339 #define __FLOG_STATIC1(subsys,compnt,text,a) |
|
340 |
|
341 #define __FLOG_STATIC2(subsys,compnt,text,a,b) |
|
342 |
|
343 #define __FLOG_STATIC3(subsys,compnt,text,a,b,c) |
|
344 |
|
345 #define __FLOG_STATIC4(subsys,compnt,text,a,b,c,d) |
|
346 |
|
347 #define __FLOG_STATIC5(subsys,compnt,text,a,b,c,d,e) |
|
348 |
|
349 #define __FLOG_STATIC6(subsys,compnt,text,a,b,c,d,e,f) |
|
350 |
|
351 #define __FLOG_STATIC7(subsys,compnt,text,a,b,c,d,e,f,g) |
|
352 |
|
353 #define __FLOG_STATIC8(subsys,compnt,text,a,b,c,d,e,f,g,h) |
|
354 |
|
355 #define __FLOG_STATIC9(subsys,compnt,text,a,b,c,d,e,f,g,h,i) |
|
356 |
|
357 #define __FLOG_STATIC(subsys,compnt,text) |
|
358 |
|
359 #define __FLOG_STATIC_VA(args) |
|
360 |
|
361 #define __FLOG_STATIC_HEXDUMP(args) |
|
362 |
|
363 |
|
364 #endif |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 #endif // __COMMSDEBUGUTILITY_H__ |