|
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 White List Adapter. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef WHITELISTADAPTER_LOGGER_H |
|
22 #define WHITELISTADAPTER_LOGGER_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <e32std.h> |
|
27 #include <e32def.h> |
|
28 #include <flogger.h> |
|
29 |
|
30 // TYPES |
|
31 |
|
32 enum TWhiteListAdapterLogMask ///< Log mask bits. |
|
33 { |
|
34 ELogOff = 0x00000000, ///< Don't log. |
|
35 ELogBasic = 0x00000001, ///< Log only basic activities. |
|
36 ELogDetailed = 0x00000002, ///< Detailed activities use this mask. |
|
37 ELogAll = 0xFFFFFFFF ///< Log all. |
|
38 }; |
|
39 |
|
40 // MACROS |
|
41 |
|
42 // Determines what to log. Construct this from TWhiteListAdapterLogMask values. |
|
43 #define WHITELISTADAPTER_LOG_MASK ELogAll |
|
44 /// Determines log detail (0==basic level). |
|
45 #define WHITELISTADAPTER_LOG_LEVEL 5 |
|
46 |
|
47 // CLASS DECLARATION |
|
48 |
|
49 /** |
|
50 * Logger class. |
|
51 */ |
|
52 class WhiteListAdapterLogger |
|
53 { |
|
54 public: // new methods |
|
55 |
|
56 /** |
|
57 * Write formatted log. |
|
58 * @param aMask Log mask. |
|
59 * @param aLevel Log level. |
|
60 * @param aFmt Format string. |
|
61 */ |
|
62 static void Write |
|
63 ( TInt32 aMask, TInt aLevel, TRefByValue<const TDesC16> aFmt, ... ); |
|
64 |
|
65 /** |
|
66 * Write formatted log. |
|
67 * @param aMask Log mask. |
|
68 * @param aLevel Log level. |
|
69 * @param aFmt Format string. |
|
70 * @param aList Variable argument list. |
|
71 */ |
|
72 static void Write |
|
73 ( |
|
74 TInt32 aMask, |
|
75 TInt aLevel, |
|
76 TRefByValue<const TDesC16> aFmt, |
|
77 VA_LIST& aList |
|
78 ); |
|
79 |
|
80 /** |
|
81 * Write formatted log. |
|
82 * @param aMask Log mask. |
|
83 * @param aLevel Log level. |
|
84 * @param aFmt Format string. |
|
85 */ |
|
86 static void Write |
|
87 ( TInt32 aMask, TInt aLevel, TRefByValue<const TDesC8> aFmt, ... ); |
|
88 |
|
89 /** |
|
90 * Write formatted log. |
|
91 * @param aMask Log mask. |
|
92 * @param aLevel Log level. |
|
93 * @param aFmt Format string. |
|
94 * @param aList Variable argument list. |
|
95 */ |
|
96 static void Write |
|
97 ( |
|
98 TInt32 aMask, |
|
99 TInt aLevel, |
|
100 TRefByValue<const TDesC8> aFmt, |
|
101 VA_LIST& aList |
|
102 ); |
|
103 |
|
104 /** |
|
105 * Write hex dump. |
|
106 * @param aMask Log mask. |
|
107 * @param aLevel Log level. |
|
108 * @param aHeader Header string. |
|
109 * @param aMargin Margin. |
|
110 * @param aPtr Data. |
|
111 * @param aLen Data length. |
|
112 */ |
|
113 static void HexDump |
|
114 ( |
|
115 TInt32 aMask, |
|
116 TInt aLevel, |
|
117 const TText* aHeader, |
|
118 const TText* aMargin, |
|
119 const TUint8* aPtr, |
|
120 TInt aLen |
|
121 ); |
|
122 }; |
|
123 |
|
124 #ifdef __TEST_WHITELISTADAPTER_LOG__ |
|
125 |
|
126 /// Write formatted to log. |
|
127 #define CLOG( body ) WhiteListAdapterLogger::Write body |
|
128 /// Write hex dump. |
|
129 #define CDUMP( body ) WhiteListAdapterLogger::HexDump body |
|
130 /// Guard "log-only" argument name with this (expands to argument). |
|
131 #define LOG_ONLY( argName ) argName |
|
132 |
|
133 #else /* not defined __TEST_WHITELISTADAPTER_LOG__ */ |
|
134 |
|
135 /// Do nothing (log disabled). |
|
136 #define CLOG( body ) |
|
137 /// Do nothing (log disabled). |
|
138 #define CDUMP( body ) |
|
139 /// Guard "log-only" argument name with this (expands to nothing). |
|
140 #define LOG_ONLY( argName ) |
|
141 |
|
142 |
|
143 #endif /* def __TEST_WHITELISTADAPTER_LOG__ */ |
|
144 |
|
145 #endif /* def WHITELISTADAPTER_LOGGER_H */ |