|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Common debug functionality for this component |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef DUN_DEBUG_H |
|
20 #define DUN_DEBUG_H |
|
21 |
|
22 _LIT( KComponentName, "[DUN] " ); |
|
23 |
|
24 //#define FILE_LOGGING |
|
25 |
|
26 #ifdef _DEBUG |
|
27 |
|
28 #ifdef FILE_LOGGING |
|
29 |
|
30 #include <e32std.h> |
|
31 #include <f32file.h> |
|
32 #include <flogger.h> |
|
33 |
|
34 #define FTRACE(a) {a;} |
|
35 |
|
36 _LIT( KLogFile,"dun.txt" ); |
|
37 _LIT( KLogDir, "dun" ); |
|
38 _LIT( KLogDirFullName,"c:\\logs\\dun\\" ); |
|
39 |
|
40 // Declare the FPrint function |
|
41 // |
|
42 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... ) |
|
43 { |
|
44 VA_LIST list; |
|
45 VA_START( list, aFmt ); |
|
46 RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list ); |
|
47 } |
|
48 |
|
49 inline void FPrintRaw( const TDesC8& /*aDes*/ ) |
|
50 { |
|
51 } |
|
52 |
|
53 #else |
|
54 |
|
55 #include <e32svr.h> |
|
56 |
|
57 #define FTRACE(a) {a;} |
|
58 |
|
59 /** |
|
60 Overflow handler for VA_LIST parsing into a fixed size buffer to |
|
61 be printed out using RDebug. |
|
62 */ |
|
63 NONSHARABLE_CLASS( TRDebugOverflowHander ) : public TDesOverflow |
|
64 { |
|
65 /** |
|
66 The function that will get called when the buffer is over-flowed. |
|
67 In this case we just ignore the overflow, so the buffer will |
|
68 effectively be truncated. |
|
69 */ |
|
70 virtual void Overflow( TDes16& /*aDes*/ ) { return; } |
|
71 }; |
|
72 |
|
73 /** The maximum length of a log line (in characters) output using RDebug. */ |
|
74 const TUint KRDebugMaxLineLen = 0x100; |
|
75 |
|
76 // Declare the FPrint function |
|
77 // |
|
78 |
|
79 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... ) |
|
80 { |
|
81 VA_LIST list; |
|
82 VA_START( list, aFmt ); |
|
83 TRDebugOverflowHander overflow; |
|
84 TBuf<KRDebugMaxLineLen> buf; |
|
85 TRefByValue<const TDesC> fmt = aFmt; |
|
86 buf.Copy( KComponentName ); |
|
87 buf.AppendFormatList( fmt, list, &overflow ); |
|
88 RDebug::Print( buf ); |
|
89 } |
|
90 |
|
91 inline void FPrintRaw( const TDesC8& aDes ) |
|
92 { |
|
93 RDebug::RawPrint( aDes ); |
|
94 } |
|
95 |
|
96 #endif // FILE_LOGGING |
|
97 |
|
98 // =========================================================================== |
|
99 #else // // No loggings --> Reduced binary size |
|
100 // =========================================================================== |
|
101 #define FTRACE( a ) |
|
102 |
|
103 #endif // _DEBUG |
|
104 |
|
105 #endif // DUN_DEBUG_H |
|
106 |
|
107 // End of File |