|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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 * Logging macros for COD Handler. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef COD_LOGGER_H |
|
22 #define COD_LOGGER_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <e32std.h> |
|
27 #include <e32def.h> |
|
28 #include <flogger.h> |
|
29 |
|
30 // TYPES |
|
31 |
|
32 enum TCodLogMask ///< Log mask bits. |
|
33 { |
|
34 ELogOff = 0x00000000, ///< Don't log. |
|
35 EWapConn = 0x00000001, ///< Log WAP connection. |
|
36 ETcpConn = 0x00000002, ///< Log TCP connection. |
|
37 EConn = 0x00000004, ///< Log Connection. |
|
38 EHttpLoad = 0x00000008, ///< Log HTTP Loader. |
|
39 EWspHeader = 0x00000010, ///< Log WSP header handling. |
|
40 ECodEng = 0x00000020, ///< Log COD Engine. |
|
41 ECharset = 0x00000040, ///< Log charset conversions. |
|
42 EParse = 0x00000080, ///< Log parsing. |
|
43 ECodStorage = 0x00000100, ///< Log Storage. |
|
44 ELogAll = 0xFFFFFFFF ///< Log all. |
|
45 }; |
|
46 |
|
47 // MACROS |
|
48 |
|
49 /// Determines what to log. Construct this from TCodLogMask values. |
|
50 #define COD_LOG_MASK ELogAll |
|
51 /** |
|
52 * Determines log detail. |
|
53 * - 0 -> Basic level. Only key events / data. Public API method calls. |
|
54 * Failures (panics). |
|
55 * - 1 -> Basic level. More detailed about key events / data. |
|
56 * - 2 -> Medium level. Function calls are logged. |
|
57 * - 3 -> Medium level. More detailed. Observer callbacks. |
|
58 * - 4 -> Detailed level. |
|
59 * - 5 -> Detailed level. Most detailed, log grows very big. |
|
60 */ |
|
61 #define COD_LOG_LEVEL 4 |
|
62 |
|
63 #ifdef _DEBUG |
|
64 |
|
65 /// Defining this enables COD logging. Needs flogger.lib. |
|
66 #define __TEST_COD_LOG |
|
67 |
|
68 #endif /* def _DEBUG */ |
|
69 |
|
70 #ifdef __TEST_COD_LOG |
|
71 |
|
72 // CLASS DECLARATION |
|
73 |
|
74 /** |
|
75 * Logger class. |
|
76 */ |
|
77 NONSHARABLE_CLASS( CodLogger ) |
|
78 { |
|
79 public: // new methods |
|
80 |
|
81 /** |
|
82 * Write formatted log. |
|
83 * @param aMask Log mask. |
|
84 * @param aLevel Log level. |
|
85 * @param aFmt Format string. |
|
86 */ |
|
87 static void Write |
|
88 ( TInt32 aMask, TInt aLevel, TRefByValue<const TDesC16> aFmt, ... ); |
|
89 |
|
90 /** |
|
91 * Write formatted log. |
|
92 * @param aMask Log mask. |
|
93 * @param aLevel Log level. |
|
94 * @param aFmt Format string. |
|
95 * @param aList Variable argument list. |
|
96 */ |
|
97 static void Write |
|
98 ( |
|
99 TInt32 aMask, |
|
100 TInt aLevel, |
|
101 TRefByValue<const TDesC16> aFmt, |
|
102 VA_LIST& aList |
|
103 ); |
|
104 |
|
105 /** |
|
106 * Write formatted log. |
|
107 * @param aMask Log mask. |
|
108 * @param aLevel Log level. |
|
109 * @param aFmt Format string. |
|
110 */ |
|
111 static void Write |
|
112 ( TInt32 aMask, TInt aLevel, TRefByValue<const TDesC8> aFmt, ... ); |
|
113 |
|
114 /** |
|
115 * Write formatted log. |
|
116 * @param aMask Log mask. |
|
117 * @param aLevel Log level. |
|
118 * @param aFmt Format string. |
|
119 * @param aList Variable argument list. |
|
120 */ |
|
121 static void Write |
|
122 ( |
|
123 TInt32 aMask, |
|
124 TInt aLevel, |
|
125 TRefByValue<const TDesC8> aFmt, |
|
126 VA_LIST& aList |
|
127 ); |
|
128 |
|
129 /** |
|
130 * Write hex dump. |
|
131 * @param aMask Log mask. |
|
132 * @param aLevel Log level. |
|
133 * @param aHeader Header string. |
|
134 * @param aMargin Margin. |
|
135 * @param aPtr Data. |
|
136 * @param aLen Data length. |
|
137 */ |
|
138 static void HexDump |
|
139 ( |
|
140 TInt32 aMask, |
|
141 TInt aLevel, |
|
142 const TText* aHeader, |
|
143 const TText* aMargin, |
|
144 const TUint8* aPtr, |
|
145 TInt aLen |
|
146 ); |
|
147 }; |
|
148 |
|
149 #endif /* def __TEST_COD_LOG */ |
|
150 |
|
151 #ifdef __TEST_COD_LOG |
|
152 |
|
153 /// Write formatted to log. |
|
154 #define CLOG( body ) CodLogger::Write body |
|
155 /// Write hex dump. |
|
156 #define CDUMP( body ) CodLogger::HexDump body |
|
157 /// Guard "log-only" argument name with this (expands to argument). |
|
158 #define LOG_ONLY( argName ) argName |
|
159 |
|
160 #else /* not defined __TEST_COD_LOG */ |
|
161 |
|
162 /// Do nothing (log disabled). |
|
163 #define CLOG( body ) |
|
164 /// Do nothing (log disabled). |
|
165 #define CDUMP( body ) |
|
166 /// Guard "log-only" argument name with this (expands to nothing). |
|
167 #define LOG_ONLY( argName ) |
|
168 |
|
169 #endif /* def __TEST_COD_LOG */ |
|
170 |
|
171 #ifdef _DEBUG |
|
172 |
|
173 /// Guard "debug-only" argument name with this (expands to argument). |
|
174 #define DEBUG_ONLY( argName ) argName |
|
175 |
|
176 #else /* not defined _DEBUG */ |
|
177 |
|
178 /// Guard "debug-only" argument name with this (expands to nothing). |
|
179 #define DEBUG_ONLY( argName ) |
|
180 |
|
181 #endif /* def _DEBUG */ |
|
182 |
|
183 #endif /* def COD_LOGGER_H */ |