|
1 /* |
|
2 * Copyright (c) 2006 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: Macros for logging |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef QOSCONTROLLERLOG_H |
|
22 #define QOSCONTROLLERLOG_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <e32svr.h> |
|
28 #include <utf.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * Class provides logging through RDebug in debug builds |
|
36 * 'QosController: ' added automatically in fron of every logged line |
|
37 */ |
|
38 class TQosControllerDebug |
|
39 { |
|
40 public: |
|
41 |
|
42 #ifdef _DEBUG |
|
43 |
|
44 inline static void Print(const TDesC16& aStr) |
|
45 { |
|
46 _LIT(KQosControllerFormat, "QosController: %S"); |
|
47 |
|
48 TBuf<256> str; |
|
49 str.Format(KQosControllerFormat, &aStr); |
|
50 RDebug::Print(str); |
|
51 } |
|
52 |
|
53 inline static void Print(const TDesC16& aStr1, const TDesC16& aStr2) |
|
54 { |
|
55 _LIT(KQosControllerFormat, "QosController: %S, %S"); |
|
56 TBuf<256> str; |
|
57 str.Format(KQosControllerFormat, &aStr1, &aStr2); |
|
58 RDebug::Print(str); |
|
59 } |
|
60 |
|
61 inline static void Print(const TDesC16& aStr, TUint32 aValue) |
|
62 { |
|
63 _LIT(KQosControllerFormat, "QosController: %S, %d"); |
|
64 TBuf<256> str; |
|
65 str.Format(KQosControllerFormat, &aStr, aValue); |
|
66 RDebug::Print(str); |
|
67 } |
|
68 |
|
69 inline static void Print(const TDesC16& aStr, TUint32 aValue1, TUint32 aValue2) |
|
70 { |
|
71 _LIT(KQosControllerFormat, "QosController: %S, %d, %d"); |
|
72 TBuf<256> str; |
|
73 str.Format(KQosControllerFormat, &aStr, aValue1, aValue2); |
|
74 RDebug::Print(str); |
|
75 } |
|
76 |
|
77 inline static void Print(const TDesC16& aStr, TUint32 aValue1, |
|
78 TUint32 aValue2, TUint32 aValue3) |
|
79 { |
|
80 _LIT(KQosControllerFormat, "QosController: %S, %d, %d, %d"); |
|
81 TBuf<256> str; |
|
82 str.Format(KQosControllerFormat, &aStr, aValue1, aValue2, aValue3); |
|
83 RDebug::Print(str); |
|
84 } |
|
85 |
|
86 inline static void Print(const TDesC16& aStr1, const TDesC8& aStr2) |
|
87 { |
|
88 TBuf<100> str2; |
|
89 CnvUtfConverter::ConvertToUnicodeFromUtf8(str2, aStr2); |
|
90 |
|
91 _LIT(KQosControllerFormat, "QosController: %S, %S"); |
|
92 TBuf<256> str; |
|
93 str.Format(KQosControllerFormat, &aStr1, &str2); |
|
94 RDebug::Print(str); |
|
95 } |
|
96 |
|
97 #else |
|
98 |
|
99 inline static void Print(const TDesC16& /*aStr*/) |
|
100 { |
|
101 } |
|
102 |
|
103 inline static void Print(const TDesC16& /*aStr1*/, const TDesC16& /*aStr1*/) |
|
104 { |
|
105 } |
|
106 |
|
107 inline static void Print(const TDesC16& /*aStr*/, TUint32 /*aValue*/) |
|
108 { |
|
109 } |
|
110 |
|
111 inline static void Print(const TDesC16& /*aStr*/, TUint32 /*aValue1*/, TUint32 /*aValue2*/) |
|
112 { |
|
113 } |
|
114 |
|
115 inline static void Print(const TDesC16& /*aStr*/, TUint32 /*aValue1*/, |
|
116 TUint32 /*aValue2*/, TUint32 /*aValue3*/) |
|
117 { |
|
118 } |
|
119 |
|
120 inline static void Print(const TDesC16& /*aStr1*/, const TDesC8& /*aStr2*/) |
|
121 { |
|
122 } |
|
123 |
|
124 #endif |
|
125 |
|
126 }; |
|
127 |
|
128 /** |
|
129 * Macro for logging single string |
|
130 * __TRACE_MCC_QOS_CONTROLLER1("Hello") |
|
131 * Note, max length of printed line 256 characters |
|
132 */ |
|
133 #define __TRACE_MCC_QOS_CONTROLLER1( a ) { TQosControllerDebug::Print( _L( a ) ); } |
|
134 |
|
135 /** |
|
136 * Macro for logging two strings |
|
137 * __TRACE_MCC_QOS_CONTROLLER2("Hello", "Back") |
|
138 * Note, max length of printed line 256 characters |
|
139 */ |
|
140 #define __TRACE_MCC_QOS_CONTROLLER2( a, b ) { TQosControllerDebug::Print( _L( a ), _L( b ) ); } |
|
141 |
|
142 /** |
|
143 * Macro for logging a string and integer |
|
144 * __TRACE_MCC_QOS_CONTROLLER3("Hello", 1) |
|
145 * Note, max length of printed line 256 characters |
|
146 */ |
|
147 #define __TRACE_MCC_QOS_CONTROLLER3( a, b ) { TQosControllerDebug::Print( _L( a ), b ); } |
|
148 |
|
149 /** |
|
150 * Macro for logging a string and 2 integers |
|
151 * __TRACE_MCC_QOS_CONTROLLER4("Hello", 1, 2) |
|
152 * Note, max length of printed line 256 characters |
|
153 */ |
|
154 #define __TRACE_MCC_QOS_CONTROLLER4( a, b, c ) { TQosControllerDebug::Print( _L( a ), b , c); } |
|
155 |
|
156 /** |
|
157 * Macro for logging a string and 3 integers |
|
158 * __TRACE_MCC_QOS_CONTROLLER5("Hello", 1, 2, 3) |
|
159 * Note, max length of printed line 256 characters |
|
160 */ |
|
161 #define __TRACE_MCC_QOS_CONTROLLER5( a, b, c, d ) { TQosControllerDebug::Print( _L( a ), b , c, d); } |
|
162 |
|
163 /** |
|
164 * Macro for logging a string and variable string |
|
165 * __TRACE_MCC_QOS_CONTROLLER6("Hello", string) |
|
166 * Note, max length of printed line 256 characters |
|
167 */ |
|
168 #define __TRACE_MCC_QOS_CONTROLLER6( a, b) { TQosControllerDebug::Print( _L( a ), b ); } |
|
169 |
|
170 #endif |