|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef MCETESTUILOGS_H |
|
24 #define MCETESTUILOGS_H |
|
25 |
|
26 #include <e32std.h> |
|
27 |
|
28 // INCLUDES |
|
29 |
|
30 #include <e32base.h> |
|
31 #include <e32svr.h> |
|
32 #include <utf.h> |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Class provides logging through RDebug in debug builds |
|
40 * '***MCETestUI***: ' added automatically in fron of every logged line |
|
41 */ |
|
42 class TMceTestUIDebug |
|
43 { |
|
44 public: |
|
45 |
|
46 #ifdef _DEBUG |
|
47 |
|
48 inline static void Print(const TDesC16& aStr) |
|
49 { |
|
50 TChar notAllowed('%'); |
|
51 if ( aStr.Locate( notAllowed ) == KErrNotFound ) |
|
52 { |
|
53 _LIT(KMceFormat, "***MCETestUI***: %S"); |
|
54 |
|
55 TBuf<256> str; |
|
56 str.Format(KMceFormat, &aStr); |
|
57 RDebug::Print(str); |
|
58 } |
|
59 else |
|
60 { |
|
61 _LIT(KMceWarning, "***MCETestUI***: Text contains not allowed characters, log ignored"); |
|
62 RDebug::Print( KMceWarning ); |
|
63 } |
|
64 } |
|
65 |
|
66 inline static void Print(const TDesC16& aStr1, const TDesC16& aStr2) |
|
67 { |
|
68 TChar notAllowed('%'); |
|
69 if ( aStr1.Locate( notAllowed ) == KErrNotFound && |
|
70 aStr2.Locate( notAllowed ) == KErrNotFound ) |
|
71 { |
|
72 _LIT(KMceFormat, "***MCETestUI***: %S, %S"); |
|
73 TBuf<256> str; |
|
74 str.Format(KMceFormat, &aStr1, &aStr2); |
|
75 RDebug::Print(str); |
|
76 } |
|
77 else |
|
78 { |
|
79 _LIT(KMceWarning, "***MCETestUI***:: Text contains not allowed characters, log ignored"); |
|
80 RDebug::Print( KMceWarning ); |
|
81 } |
|
82 } |
|
83 |
|
84 inline static void Print(const TDesC16& aStr, TUint32 aValue) |
|
85 { |
|
86 TChar notAllowed('%'); |
|
87 if ( aStr.Locate( notAllowed ) == KErrNotFound ) |
|
88 { |
|
89 _LIT(KMceFormat, "***MCETestUI***: %S, %d"); |
|
90 TBuf<256> str; |
|
91 str.Format(KMceFormat, &aStr, aValue); |
|
92 RDebug::Print(str); |
|
93 } |
|
94 else |
|
95 { |
|
96 _LIT(KMceWarning, "***MCETestUI***: Text contains not allowed characters, log ignored"); |
|
97 RDebug::Print( KMceWarning ); |
|
98 } |
|
99 } |
|
100 |
|
101 inline static void Print(const TDesC16& aStr, TUint32 aValue1, TUint32 aValue2) |
|
102 { |
|
103 TChar notAllowed('%'); |
|
104 if ( aStr.Locate( notAllowed ) == KErrNotFound ) |
|
105 { |
|
106 _LIT(KMceFormat, "***MCETestUI***: %S, %d, %d"); |
|
107 TBuf<256> str; |
|
108 str.Format(KMceFormat, &aStr, aValue1, aValue2); |
|
109 RDebug::Print(str); |
|
110 } |
|
111 else |
|
112 { |
|
113 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
114 RDebug::Print( KMceWarning ); |
|
115 } |
|
116 } |
|
117 |
|
118 inline static void Print(const TDesC16& aStr, TUint32 aValue1, |
|
119 TUint32 aValue2, TUint32 aValue3) |
|
120 { |
|
121 TChar notAllowed('%'); |
|
122 if ( aStr.Locate( notAllowed ) == KErrNotFound ) |
|
123 { |
|
124 _LIT(KMceFormat, "***MCETestUI***: %S, %d, %d, %d"); |
|
125 TBuf<256> str; |
|
126 str.Format(KMceFormat, &aStr, aValue1, aValue2, aValue3); |
|
127 RDebug::Print(str); |
|
128 } |
|
129 else |
|
130 { |
|
131 _LIT(KMceWarning, "***MCETestUI***: Text contains not allowed characters, log ignored"); |
|
132 RDebug::Print( KMceWarning ); |
|
133 } |
|
134 } |
|
135 |
|
136 inline static void Print(const TDesC16& aStr1, const TDesC8& aStr2) |
|
137 { |
|
138 TChar notAllowed('%'); |
|
139 if ( aStr1.Locate( notAllowed ) == KErrNotFound && |
|
140 aStr2.Locate( notAllowed ) == KErrNotFound ) |
|
141 { |
|
142 TBuf<100> str2; |
|
143 CnvUtfConverter::ConvertToUnicodeFromUtf8(str2, aStr2); |
|
144 |
|
145 _LIT(KMceFormat, "***MCETestUI***: %S, %S"); |
|
146 TBuf<256> str; |
|
147 str.Format(KMceFormat, &aStr1, &str2); |
|
148 RDebug::Print(str); |
|
149 } |
|
150 else |
|
151 { |
|
152 _LIT(KMceWarning, "***MCETestUI***: Text contains not allowed characters, log ignored"); |
|
153 RDebug::Print( KMceWarning ); |
|
154 } |
|
155 } |
|
156 |
|
157 #else |
|
158 |
|
159 inline static void Print(const TDesC16& /*aStr*/) |
|
160 { |
|
161 } |
|
162 |
|
163 inline static void Print(const TDesC16& /*aStr1*/, const TDesC16& /*aStr1*/) |
|
164 { |
|
165 } |
|
166 |
|
167 inline static void Print(const TDesC16& /*aStr*/, TUint32 /*aValue*/) |
|
168 { |
|
169 } |
|
170 |
|
171 inline static void Print(const TDesC16& /*aStr*/, TUint32 /*aValue1*/, TUint32 /*aValue2*/) |
|
172 { |
|
173 } |
|
174 |
|
175 inline static void Print(const TDesC16& /*aStr*/, TUint32 /*aValue1*/, |
|
176 TUint32 /*aValue2*/, TUint32 /*aValue3*/) |
|
177 { |
|
178 } |
|
179 |
|
180 inline static void Print(const TDesC16& /*aStr1*/, const TDesC8& /*aStr2*/) |
|
181 { |
|
182 } |
|
183 |
|
184 #endif |
|
185 |
|
186 }; |
|
187 |
|
188 /** |
|
189 * Macro for logging single string |
|
190 * MCE_DEBUG1("Hello") |
|
191 * Note, max length of printed line 256 characters |
|
192 */ |
|
193 #define MCE_TESTUI_DEBUG1( a ) { TMceTestUIDebug::Print( _L( a ) ); } |
|
194 |
|
195 /** |
|
196 * Macro for logging two strings |
|
197 * MCE_DEBUG2("Hello", "Back") |
|
198 * Note, max length of printed line 256 characters |
|
199 */ |
|
200 #define MCE_TESTUI_DEBUG2( a, b ) { TMceTestUIDebug::Print( _L( a ), _L( b ) ); } |
|
201 |
|
202 /** |
|
203 * Macro for logging a string and integer |
|
204 * MCE_DEBUG3("Hello", 1) |
|
205 * Note, max length of printed line 256 characters |
|
206 */ |
|
207 #define MCE_TESTUI_DEBUG3( a, b ) { TMceTestUIDebug::Print( _L( a ), b ); } |
|
208 |
|
209 /** |
|
210 * Macro for logging a string and 2 integers |
|
211 * MCE_DEBUG4("Hello", 1, 2) |
|
212 * Note, max length of printed line 256 characters |
|
213 */ |
|
214 #define MCE_TESTUI_DEBUG4( a, b, c ) { TMceTestUIDebug::Print( _L( a ), b , c); } |
|
215 |
|
216 /** |
|
217 * Macro for logging a string and 3 integers |
|
218 * MCE_DEBUG5("Hello", 1, 2, 3) |
|
219 * Note, max length of printed line 256 characters |
|
220 */ |
|
221 #define MCE_TESTUI_DEBUG5( a, b, c, d ) { TMceTestUIDebug::Print( _L( a ), b , c, d); } |
|
222 |
|
223 /** |
|
224 * Macro for logging a string and variable string |
|
225 * MCE_DEBUG6("Hello", string) |
|
226 * Note, max length of printed line 256 characters |
|
227 */ |
|
228 #define MCE_TESTUI_DEBUG6( a, b) { TMceTestUIDebug::Print( _L( a ), b ); } |
|
229 |
|
230 #endif |