|
1 // Copyright (c) 2007-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 // node message logging |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 |
|
24 #ifndef SYMBIAN_NM_LOG_H |
|
25 #define SYMBIAN_NM_LOG_H |
|
26 |
|
27 // Enable logging for debug builds or builds with the comms flogger enabled - must be defined before including e32utrace.h |
|
28 #if (defined(_DEBUG) || defined(__FLOG_ACTIVE)) && !defined(SYMBIAN_TRACE_ENABLE) |
|
29 #define SYMBIAN_TRACE_ENABLE |
|
30 #endif |
|
31 |
|
32 #include <e32utrace.h> |
|
33 #include <e32des8.h> |
|
34 |
|
35 namespace Messages |
|
36 { |
|
37 |
|
38 class TSignalBase; |
|
39 class TRuntimeCtxId; |
|
40 class ANode; |
|
41 |
|
42 const TInt KMaxLogTextLength = 250; |
|
43 |
|
44 class TLogTextBuf : public TBuf8<KMaxLogTextLength> |
|
45 { |
|
46 public: |
|
47 class TLogIgnoreOverflow8 : public TDes8Overflow |
|
48 { |
|
49 public: |
|
50 void Overflow(TDes8& /*aDes*/) { } |
|
51 }; |
|
52 |
|
53 void AppendFormatIgnoreOverflow(TRefByValue<const TDesC8> aFmt, ...) |
|
54 { |
|
55 TLogIgnoreOverflow8 overflowHandler; |
|
56 VA_LIST list; |
|
57 VA_START(list, aFmt); |
|
58 AppendFormatList(aFmt, list, &overflowHandler); |
|
59 VA_END(list); |
|
60 } |
|
61 |
|
62 void AppendFormatIgnoreOverflow(TRefByValue<const TDesC8> aFmt, VA_LIST& aList) |
|
63 { |
|
64 TLogIgnoreOverflow8 overflowHandler; |
|
65 AppendFormatList(aFmt, aList, &overflowHandler); |
|
66 } |
|
67 }; |
|
68 |
|
69 class Logging |
|
70 { |
|
71 public: |
|
72 // These are used in the btrace/utrace log output as the SubCategory/Schema |
|
73 enum TLogEntryType |
|
74 { |
|
75 ELogBinary = KBinary, // Binary dump = 0 |
|
76 ELogInfo = KText, // Text output = 1 |
|
77 |
|
78 ELogBlockStart, // = 2 |
|
79 ELogBlockEnd, // = 3 |
|
80 ELogNodeCreate, // = 4 |
|
81 ELogNodeDestroy, // = 5 |
|
82 ELogAddress, // = 6 |
|
83 ELogMessage, // = 7 |
|
84 ELogNode, // = 8 |
|
85 }; |
|
86 |
|
87 private: |
|
88 enum |
|
89 { |
|
90 KPrimaryFilter = 194 |
|
91 }; |
|
92 |
|
93 public: |
|
94 // General logging statememts |
|
95 IMPORT_C static void Printf(const TDesC8& aSubTag, TRefByValue<const TDesC8> aFmt, ...); |
|
96 IMPORT_C static void Printf(const TDesC8& aSubTag, TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
97 IMPORT_C static void Printf(const TDesC8& aSubTag, TLogEntryType aType, TRefByValue<const TDesC8> aFmt, ...); |
|
98 IMPORT_C static void Printf(const TDesC8& aSubTag, TLogEntryType aType, TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
99 |
|
100 IMPORT_C static void LogAddress(const TDesC8& aSubTag, const TRuntimeCtxId& aAddress, const TDesC8& aText); |
|
101 IMPORT_C static void LogAddress(const TDesC8& aSubTag, const TRuntimeCtxId& aAddress); |
|
102 IMPORT_C static void LogMessage(const TDesC8& aSubTag, const TDesC8& aMessage, const TDesC8& aText); |
|
103 IMPORT_C static void LogMessage(const TDesC8& aSubTag, const TDesC8& aMessage); |
|
104 IMPORT_C static void LogMessage(const TDesC8& aSubTag, const TSignalBase& aMessage, const TDesC8& aText); |
|
105 IMPORT_C static void LogMessage(const TDesC8& aSubTag, const TSignalBase& aMessage); |
|
106 IMPORT_C static void LogNode(const TDesC8& aSubTag, const ANode& aNode, const TDesC8& aText); |
|
107 IMPORT_C static void LogNode(const TDesC8& aSubTag, const ANode& aNode); |
|
108 }; |
|
109 |
|
110 } // namespace Messages |
|
111 |
|
112 |
|
113 #ifdef SYMBIAN_TRACE_ENABLE |
|
114 |
|
115 _LIT8(KNodeMessagesSubTag, "nodemsg"); |
|
116 |
|
117 // Local helper macros - don't use these directly |
|
118 #define NM_LOG_NODE_CREATE_ARG0(typeName) _L8(#typeName " %08x:\tcreated [ANode=0x%08x] [%d]" ), this, static_cast<Messages::ANodeId*>(this)->Id().Ptr(), sizeof(typeName) |
|
119 #define NM_LOG_NODE_CREATE_ARG1(typeName, formatText, a1) _L8(#typeName " %08x:\tcreated [ANode=0x%08x] [%d] " formatText), this, static_cast<Messages::ANodeId*>(this)->Id().Ptr(), sizeof(typeName), a1 |
|
120 #define NM_LOG_NODE_CREATE_ARG2(typeName, formatText, a1, a2) _L8(#typeName " %08x:\tcreated [ANode=0x%08x] [%d] " formatText), this, static_cast<Messages::ANodeId*>(this)->Id().Ptr(), sizeof(typeName), a1, a2 |
|
121 #define NM_LOG_NODE_CREATE_ARG3(typeName, formatText, a1, a2, a3) _L8(#typeName " %08x:\tcreated [ANode=0x%08x] [%d] " formatText), this, static_cast<Messages::ANodeId*>(this)->Id().Ptr(), sizeof(typeName), a1, a2, a3 |
|
122 |
|
123 #define NM_LOG_NODE_DESTROY_ARG0(typeName) _L8(#typeName " %08x:\t~" #typeName " [ANode=0x%08x]" ), this, static_cast<Messages::ANodeId*>(this)->Id().Ptr() |
|
124 #define NM_LOG_NODE_DESTROY_ARG1(typeName, formatText, a1) _L8(#typeName " %08x:\t~" #typeName " [ANode=0x%08x]" formatText), this, static_cast<Messages::ANodeId*>(this)->Id().Ptr(), a1 |
|
125 #define NM_LOG_NODE_DESTROY_ARG2(typeName, formatText, a1, a2) _L8(#typeName " %08x:\t~" #typeName " [ANode=0x%08x]" formatText), this, static_cast<Messages::ANodeId*>(this)->Id().Ptr(), a1, a2 |
|
126 #define NM_LOG_NODE_DESTROY_ARG3(typeName, formatText, a1, a2, a3) _L8(#typeName " %08x:\t~" #typeName " [ANode=0x%08x]" formatText), this, static_cast<Messages::ANodeId*>(this)->Id().Ptr(), a1, a2, a3 |
|
127 |
|
128 |
|
129 // Node Messages general logging |
|
130 #define NM_LOG(logArgs) Messages::Logging::Printf logArgs ; |
|
131 #define NM_LOG_STMT(statement) statement ; |
|
132 |
|
133 |
|
134 // Node creation logging macros |
|
135 #define NM_LOG_NODE_CREATE(subTag, typeName) \ |
|
136 NM_LOG((subTag, Messages::Logging::ELogNodeCreate, NM_LOG_NODE_CREATE_ARG0(typeName))) |
|
137 |
|
138 #define NM_LOG_NODE_CREATE1(subTag, typeName, formatText, arg1) \ |
|
139 NM_LOG((subTag, Messages::Logging::ELogNodeCreate, NM_LOG_NODE_CREATE_ARG1(typeName, formatText, arg1))) |
|
140 |
|
141 #define NM_LOG_NODE_CREATE2(subTag, typeName, formatText, arg1, arg2) \ |
|
142 NM_LOG((subTag, Messages::Logging::ELogNodeCreate, NM_LOG_NODE_CREATE_ARG2(typeName, formatText, arg1, arg2))) |
|
143 |
|
144 #define NM_LOG_NODE_CREATE3(subTag, typeName, formatText, arg1, arg2, arg3) \ |
|
145 NM_LOG((subTag, Messages::Logging::ELogNodeCreate, NM_LOG_NODE_CREATE_ARG3(typeName, formatText, arg1, arg2, arg3))) |
|
146 |
|
147 |
|
148 // Node destruction logging macros |
|
149 #define NM_LOG_NODE_DESTROY(subTag, typeName) \ |
|
150 NM_LOG((subTag, Messages::Logging::ELogNodeDestroy, NM_LOG_NODE_DESTROY_ARG0(typeName))) |
|
151 |
|
152 #define NM_LOG_NODE_DESTROY1(subTag, typeName, formatText, arg1) \ |
|
153 NM_LOG((subTag, Messages::Logging::ELogNodeDestroy, NM_LOG_NODE_DESTROY_ARG1(typeName, formatText, arg1))) |
|
154 |
|
155 #define NM_LOG_NODE_DESTROY2(subTag, typeName, formatText, arg1, arg2) \ |
|
156 NM_LOG((subTag, Messages::Logging::ELogNodeDestroy, NM_LOG_NODE_DESTROY_ARG2(typeName, formatText, arg1, arg2))) |
|
157 |
|
158 #define NM_LOG_NODE_DESTROY3(subTag, typeName, formatText, arg1, arg2, arg3) \ |
|
159 NM_LOG((subTag, Messages::Logging::ELogNodeDestroy, NM_LOG_NODE_DESTROY_ARG3(typeName, formatText, arg1, arg2, arg3))) |
|
160 |
|
161 |
|
162 #define NM_LOG_START_BLOCK(subTag, blockTag) { Messages::Logging::Printf(subTag, Messages::Logging::ELogBlockStart, blockTag); |
|
163 #define NM_LOG_END_BLOCK(subTag, blockTag) Messages::Logging::Printf(subTag, Messages::Logging::ELogBlockEnd, blockTag); } |
|
164 |
|
165 |
|
166 |
|
167 #define NM_LOG_ADDRESS(subTag, address) \ |
|
168 Messages::Logging::LogAddress(subTag, address, _L8(#address ": ")) |
|
169 |
|
170 #define NM_LOG_ADDRESS_EXT(subTag, address, logTxt) \ |
|
171 Messages::Logging::LogAddress(subTag, address, logTxt) |
|
172 |
|
173 |
|
174 |
|
175 #define NM_LOG_MESSAGE(subTag, message) \ |
|
176 Messages::Logging::LogMessage(subTag, message, _L8(#message ": ")) |
|
177 |
|
178 #define NM_LOG_MESSAGE_EXT(subTag, message, logTxt) \ |
|
179 Messages::Logging::LogMessage(subTag, message, logTxt) |
|
180 |
|
181 |
|
182 |
|
183 #define NM_LOG_NODE(subTag, node) \ |
|
184 Messages::Logging::LogNode(subTag, node, _L8(#node ": ")) |
|
185 |
|
186 #define NM_LOG_NODE_EXT(subTag, node, logTxt) \ |
|
187 Messages::Logging::LogNode(subTag, node, logTxt) |
|
188 |
|
189 |
|
190 #else |
|
191 //! SYMBIAN_TRACE_ENABLE |
|
192 |
|
193 |
|
194 #define NM_LOG_NODE_CREATE_ARG0(typeName) |
|
195 #define NM_LOG_NODE_CREATE_ARG1(typeName, formatText, a1) |
|
196 #define NM_LOG_NODE_CREATE_ARG2(typeName, formatText, a1, a2) |
|
197 #define NM_LOG_NODE_CREATE_ARG3(typeName, formatText, a1, a2, a3) |
|
198 |
|
199 #define NM_LOG_NODE_DESTROY_ARG0(typeName) |
|
200 #define NM_LOG_NODE_DESTROY_ARG1(typeName, formatText, a1) |
|
201 #define NM_LOG_NODE_DESTROY_ARG2(typeName, formatText, a1, a2) |
|
202 #define NM_LOG_NODE_DESTROY_ARG3(typeName, formatText, a1, a2, a3) |
|
203 |
|
204 #define NM_LOG(logArgs) |
|
205 #define NM_LOG_STMT(statement) |
|
206 |
|
207 #define NM_LOG_NODE_CREATE(subTag, typeName) |
|
208 #define NM_LOG_NODE_CREATE1(subTag, typeName, formatText, arg1) |
|
209 #define NM_LOG_NODE_CREATE2(subTag, typeName, formatText, arg1, arg2) |
|
210 #define NM_LOG_NODE_CREATE3(subTag, typeName, formatText, arg1, arg2, arg3) |
|
211 |
|
212 #define NM_LOG_NODE_DESTROY(subTag, typeName) |
|
213 #define NM_LOG_NODE_DESTROY1(subTag, typeName, formatText, arg1) |
|
214 #define NM_LOG_NODE_DESTROY2(subTag, typeName, formatText, arg1, arg2) |
|
215 #define NM_LOG_NODE_DESTROY3(subTag, typeName, formatText, arg1, arg2, arg3) |
|
216 |
|
217 #define NM_LOG_START_BLOCK(subTag, blockTag) |
|
218 #define NM_LOG_END_BLOCK(subTag, blockTag) |
|
219 |
|
220 #define NM_LOG_ADDRESS(subTag, address) |
|
221 #define NM_LOG_ADDRESS_EXT(subTag, address, logTxt) |
|
222 #define NM_LOG_MESSAGE(subTag, message) |
|
223 #define NM_LOG_MESSAGE_EXT(subTag, message, logTxt) |
|
224 #define NM_LOG_NODE(subTag, node) |
|
225 #define NM_LOG_NODE_EXT(subTag, node, logTxt) |
|
226 |
|
227 #endif |
|
228 // SYMBIAN_TRACE_ENABLE |
|
229 |
|
230 |
|
231 #endif |
|
232 // SYMBIAN_NM_LOG_H |
|
233 |