|
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 #ifndef MCCLOGS_H |
|
22 #define MCCLOGS_H |
|
23 |
|
24 #include <utf.h> |
|
25 #include <e32debug.h> |
|
26 |
|
27 _LIT( KMccWarning, "Mcc: Text contains not allowed characters, log ignored" ); |
|
28 |
|
29 class TMccLog |
|
30 { |
|
31 public: |
|
32 |
|
33 inline static void Print( const TDesC16& aName, const TDesC16& aStr ) |
|
34 { |
|
35 TChar notAllowed('%'); |
|
36 if ( aStr.Locate( notAllowed ) == KErrNotFound ) |
|
37 { |
|
38 TBuf<128> str; |
|
39 _LIT( KMcc, "%S %S" ); |
|
40 str.Format( KMcc(), &aName, &aStr ); |
|
41 RDebug::Print(str); |
|
42 } |
|
43 else |
|
44 { |
|
45 RDebug::Print( KMccWarning ); |
|
46 } |
|
47 } |
|
48 |
|
49 inline static void Print( |
|
50 const TDesC16& aName, |
|
51 const TDesC16& aStr, |
|
52 TInt aValue ) |
|
53 { |
|
54 TChar notAllowed('%'); |
|
55 if ( aStr.Locate( notAllowed ) == KErrNotFound ) |
|
56 { |
|
57 TBuf<128> str; |
|
58 _LIT( KMcc, "%S %S %d" ); |
|
59 str.Format( KMcc(), &aName, &aStr, aValue ); |
|
60 RDebug::Print(str); |
|
61 } |
|
62 else |
|
63 { |
|
64 RDebug::Print( KMccWarning ); |
|
65 } |
|
66 } |
|
67 |
|
68 inline static void Print( |
|
69 const TDesC16& aName, |
|
70 const TDesC16& aStr1, |
|
71 TInt aValue1, |
|
72 const TDesC16& aStr2, |
|
73 TInt aValue2) |
|
74 { |
|
75 TChar notAllowed('%'); |
|
76 if ( aStr1.Locate( notAllowed ) == KErrNotFound && |
|
77 aStr2.Locate( notAllowed ) == KErrNotFound) |
|
78 { |
|
79 TBuf<200> str; |
|
80 _LIT( KMcc, "%S %S %d, %S %d" ); |
|
81 str.Format( KMcc(), &aName, &aStr1, aValue1, |
|
82 &aStr2, aValue2 ); |
|
83 RDebug::Print(str); |
|
84 } |
|
85 else |
|
86 { |
|
87 RDebug::Print( KMccWarning ); |
|
88 } |
|
89 } |
|
90 |
|
91 inline static void Print( |
|
92 const TDesC16& aName, |
|
93 const TDesC16& aStr1, |
|
94 TInt aValue1, |
|
95 const TDesC16& aStr2, |
|
96 TInt aValue2, |
|
97 const TDesC16& aStr3, |
|
98 TInt aValue3, |
|
99 const TDesC16& aStr4, |
|
100 TInt aValue4) |
|
101 { |
|
102 TChar notAllowed('%'); |
|
103 if ( aStr1.Locate( notAllowed ) == KErrNotFound && |
|
104 aStr2.Locate( notAllowed ) == KErrNotFound && |
|
105 aStr3.Locate( notAllowed ) == KErrNotFound && |
|
106 aStr3.Locate( notAllowed ) == KErrNotFound) |
|
107 { |
|
108 TBuf<256> str; |
|
109 _LIT( KMcc, "%S %S %d, %S %d, %S %d, %S %d" ); |
|
110 str.Format( KMcc(), &aName, &aStr1, aValue1, |
|
111 &aStr2, aValue2, &aStr3, aValue3, &aStr4, aValue4 ); |
|
112 RDebug::Print(str); |
|
113 } |
|
114 else |
|
115 { |
|
116 RDebug::Print( KMccWarning ); |
|
117 } |
|
118 } |
|
119 |
|
120 inline static void Print( |
|
121 const TDesC16& aName, |
|
122 const TDesC16& aStr1, |
|
123 TInt aValue1, |
|
124 TInt aValue2) |
|
125 { |
|
126 TChar notAllowed('%'); |
|
127 if ( aStr1.Locate( notAllowed ) == KErrNotFound ) |
|
128 { |
|
129 TBuf<140> str; |
|
130 _LIT( KMcc, "%S %S %d, %d" ); |
|
131 str.Format( KMcc(), &aName, &aStr1, aValue1, |
|
132 aValue2 ); |
|
133 RDebug::Print(str); |
|
134 } |
|
135 else |
|
136 { |
|
137 RDebug::Print( KMccWarning ); |
|
138 } |
|
139 } |
|
140 |
|
141 inline static void Print( |
|
142 const TDesC16& aName, |
|
143 const TDesC16& aStrA, |
|
144 const TDesC8& aStrB) |
|
145 { |
|
146 TChar notAllowed('%'); |
|
147 if ( aName.Locate( notAllowed ) == KErrNotFound && |
|
148 aStrB.Locate( notAllowed ) == KErrNotFound ) |
|
149 { |
|
150 TBuf<128> str; |
|
151 _LIT( KMcc, "%S, %S" ); |
|
152 _LIT( KMcc2, "%S" ); |
|
153 str.Format( KMcc(), &aName, &aStrA ); |
|
154 RDebug::Print( str ); |
|
155 |
|
156 const TInt KMccLogWriteBufSize = 50; |
|
157 TInt lastPos( aStrB.Length() - 1 ); |
|
158 TInt prevPos = 0; |
|
159 TInt readLen = ( lastPos < KMccLogWriteBufSize ) ? ( lastPos + 1 ) : KMccLogWriteBufSize; |
|
160 while ( prevPos < lastPos ) |
|
161 { |
|
162 TBuf<128> str2; |
|
163 CnvUtfConverter::ConvertToUnicodeFromUtf8( str2, aStrB.Mid( prevPos, readLen ) ); |
|
164 str.Format( KMcc2(), &str2 ); |
|
165 RDebug::Print( str ); |
|
166 prevPos += readLen; |
|
167 readLen = ( prevPos + KMccLogWriteBufSize ) > lastPos ? |
|
168 ( lastPos - prevPos + 1 ) : KMccLogWriteBufSize; |
|
169 } |
|
170 |
|
171 } |
|
172 else |
|
173 { |
|
174 RDebug::Print( KMccWarning ); |
|
175 } |
|
176 } |
|
177 |
|
178 inline static void PrintReal( |
|
179 const TDesC16& aName, |
|
180 const TDesC16& aStr, |
|
181 TReal aValue ) |
|
182 { |
|
183 TChar notAllowed('%'); |
|
184 if ( aStr.Locate( notAllowed ) == KErrNotFound ) |
|
185 { |
|
186 TBuf<128> str; |
|
187 _LIT( KMcc, "%S %S %f" ); |
|
188 str.Format( KMcc(), &aName, &aStr, aValue ); |
|
189 RDebug::Print(str); |
|
190 } |
|
191 else |
|
192 { |
|
193 RDebug::Print( KMccWarning ); |
|
194 } |
|
195 } |
|
196 |
|
197 }; |
|
198 |
|
199 #endif // end of class TMccLog |
|
200 |
|
201 // End of File |