|
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 MCEEVENTSLOGS_H |
|
24 #define MCEEVENTSLOGS_H |
|
25 |
|
26 #include "mcelogs.h" |
|
27 |
|
28 // INCLUDES |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * Class provides logging through RDebug in debug builds |
|
36 * 'MCE: ' added automatically in fron of every logged line |
|
37 */ |
|
38 class TMceEventsDebug |
|
39 { |
|
40 public: |
|
41 |
|
42 #ifdef _DEBUG |
|
43 |
|
44 inline static void Print(const TDesC16& aStr) |
|
45 { |
|
46 TChar notAllowed('%'); |
|
47 if ( aStr.Locate( notAllowed ) == KErrNotFound ) |
|
48 { |
|
49 _LIT(KMceFormat, "[EVENTS] %S"); |
|
50 |
|
51 TBuf<256> str; |
|
52 str.Format(KMceFormat, &aStr); |
|
53 TMceDebug::Print( str ); |
|
54 } |
|
55 else |
|
56 { |
|
57 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
58 RDebug::Print( KMceWarning ); |
|
59 } |
|
60 } |
|
61 |
|
62 inline static void Print(const TDesC16& aStr1, TUint32 aValue1 ) |
|
63 { |
|
64 TChar notAllowed('%'); |
|
65 if ( aStr1.Locate( notAllowed ) == KErrNotFound ) |
|
66 { |
|
67 _LIT(KMceFormat, "[EVENTS] %S=%d"); |
|
68 TBuf<256> str; |
|
69 str.Format(KMceFormat, &aStr1, aValue1); |
|
70 TMceDebug::Print( str ); |
|
71 } |
|
72 else |
|
73 { |
|
74 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
75 RDebug::Print( KMceWarning ); |
|
76 } |
|
77 } |
|
78 |
|
79 inline static void Print( const TDesC16& aStr1, const TDesC16& aStr2 ) |
|
80 { |
|
81 TChar notAllowed('%'); |
|
82 if ( aStr1.Locate( notAllowed ) == KErrNotFound && |
|
83 aStr2.Locate( notAllowed ) == KErrNotFound ) |
|
84 { |
|
85 _LIT(KMceFormat, "[EVENTS] %S=%S"); |
|
86 TBuf<256> str; |
|
87 str.Format(KMceFormat, &aStr1, &aStr2); |
|
88 TMceDebug::Print( str ); |
|
89 } |
|
90 else |
|
91 { |
|
92 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
93 RDebug::Print( KMceWarning ); |
|
94 } |
|
95 } |
|
96 |
|
97 inline static void Print(const TDesC16& aStr1, TUint32 aValue1, const TDesC16& aStr2, TUint32 aValue2 ) |
|
98 { |
|
99 TChar notAllowed('%'); |
|
100 if ( aStr1.Locate( notAllowed ) == KErrNotFound ) |
|
101 { |
|
102 _LIT(KMceFormat, "[EVENTS] %S=%d, %S=%d"); |
|
103 TBuf<256> str; |
|
104 str.Format(KMceFormat, &aStr1, aValue1, &aStr2, aValue2 ); |
|
105 TMceDebug::Print( str ); |
|
106 } |
|
107 else |
|
108 { |
|
109 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
110 RDebug::Print( KMceWarning ); |
|
111 } |
|
112 } |
|
113 |
|
114 inline static void Print( const TDesC16& aStr1, const TDesC8& aValue1 ) |
|
115 { |
|
116 TChar notAllowed('%'); |
|
117 if ( aStr1.Locate( notAllowed ) == KErrNotFound ) |
|
118 { |
|
119 TBuf<100> str2; |
|
120 CnvUtfConverter::ConvertToUnicodeFromUtf8(str2, aValue1); |
|
121 |
|
122 _LIT(KMceFormat, "[EVENTS] %S=\"%S\""); |
|
123 TBuf<256> str; |
|
124 str.Format(KMceFormat, &aStr1, &str2); |
|
125 TMceDebug::Print( str ); |
|
126 } |
|
127 else |
|
128 { |
|
129 _LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored"); |
|
130 RDebug::Print( KMceWarning ); |
|
131 } |
|
132 } |
|
133 |
|
134 |
|
135 #endif |
|
136 |
|
137 }; |
|
138 |
|
139 |
|
140 #ifdef _DEBUG |
|
141 |
|
142 #define MCEEVENTS_DEBUG( a ) { TMceEventsDebug::Print( _L( a ) ); } |
|
143 #define MCEEVENTS_DEBUG2( a, b ) { TMceEventsDebug::Print( _L( a ), _L( b ) ); } |
|
144 #define MCEEVENTS_DEBUG_DVALUE( a, b ) { TMceEventsDebug::Print( _L( a ), b ); } |
|
145 #define MCEEVENTS_DEBUG_DVALUES( a, b, c, d ) { TMceEventsDebug::Print( _L( a ), b, _L( c ), d ); } |
|
146 #define MCEEVENTS_DEBUG_SVALUE( a, b ) { TMceEventsDebug::Print( _L( a ), b ); } |
|
147 #define MCEEVENTS_DEBUG_SVALUE16( a, b ) { TMceEventsDebug::Print( _L( a ), b ); } |
|
148 #define MCEEVENTS_DEBUG_NEXTSTATE( str, nextState )\ |
|
149 switch( nextState )\ |
|
150 {\ |
|
151 case 0:{ MCEEVENTS_DEBUG2( str, "KMceTerminatingEventStateIndex" );break; }\ |
|
152 case 1:{ MCEEVENTS_DEBUG2( str, "KMceTerminatedEventStateIndex" );break; }\ |
|
153 case 2:{ MCEEVENTS_DEBUG2( str, "KMceIdleEventStateIndex" );break; }\ |
|
154 case 3:{ MCEEVENTS_DEBUG2( str, "KMceEstablishingEventStateIndex" );break; }\ |
|
155 case 4:{ MCEEVENTS_DEBUG2( str, "KMceEstablishedEventStateIndex" );break; }\ |
|
156 default:{ MCEEVENTS_DEBUG_DVALUE( str, nextState );break; }\ |
|
157 } |
|
158 |
|
159 #define MCEEVENTS_DEBUG_NEXTCLIENTSTATE( str, nextClientState )\ |
|
160 switch( nextClientState )\ |
|
161 {\ |
|
162 case CMceEvent::EIdle:{ MCEEVENTS_DEBUG2( str, "EIdle" );break; }\ |
|
163 case CMceEvent::EPending:{ MCEEVENTS_DEBUG2( str, "EPending" );break; }\ |
|
164 case CMceEvent::EActive:{ MCEEVENTS_DEBUG2( str, "EActive" );break; }\ |
|
165 case CMceEvent::ETerminated:{ MCEEVENTS_DEBUG2( str, "ETerminated" );break; }\ |
|
166 default:{ MCEEVENTS_DEBUG_DVALUE( str, nextClientState );break; }\ |
|
167 } |
|
168 |
|
169 #else |
|
170 |
|
171 #define MCEEVENTS_DEBUG( a ) |
|
172 #define MCEEVENTS_DEBUG2( a, b ) |
|
173 #define MCEEVENTS_DEBUG_DVALUE( a, b ) |
|
174 #define MCEEVENTS_DEBUG_DVALUES( a, b, c, d ) |
|
175 #define MCEEVENTS_DEBUG_SVALUE( a, b ) |
|
176 #define MCEEVENTS_DEBUG_NEXTSTATE( str, state ) |
|
177 #define MCEEVENTS_DEBUG_NEXTCLIENTSTATE( str, state ) |
|
178 |
|
179 |
|
180 #endif |
|
181 |
|
182 #endif |
|
183 |
|
184 // End of File |
|
185 |