|
1 /* |
|
2 * Copyright (c) 2009 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: Debug print macros* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // Version : %version: 1 % |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 #ifndef __MPXVIDEO_DEBUG_H__ |
|
25 #define __MPXVIDEO_DEBUG_H__ |
|
26 |
|
27 // INCLUDES |
|
28 #include <e32std.h> |
|
29 #include <e32svr.h> |
|
30 #include <e32des16.h> |
|
31 #include <e32property.h> |
|
32 #include <flogger.h> |
|
33 #include <e32def.h> |
|
34 |
|
35 #ifdef _DEBUG |
|
36 |
|
37 class MPXDebug |
|
38 { |
|
39 public: |
|
40 inline static void NullLog( TRefByValue<const TDesC16> /*aFmt*/, ... ) |
|
41 { |
|
42 } |
|
43 |
|
44 inline static void FileLog( TRefByValue<const TDesC16> aFmt, ... ) |
|
45 { |
|
46 VA_LIST list; |
|
47 VA_START(list,aFmt); |
|
48 RFileLogger::WriteFormat( _L("Fusion"), |
|
49 _L("Fusion.txt"), |
|
50 EFileLoggingModeAppend, |
|
51 aFmt, |
|
52 list ); |
|
53 } |
|
54 }; |
|
55 |
|
56 #define FU_DEBUG MPXDebug::FileLog |
|
57 |
|
58 // MACROS |
|
59 #define MPX_ENTER_EXIT TEnterExitLog _s |
|
60 |
|
61 class TFusionLog : public TDes16Overflow |
|
62 { |
|
63 public: |
|
64 |
|
65 inline static void FusionLog( TRefByValue<const TDesC16> aFmt, ... ) |
|
66 { |
|
67 TBuf< 512 > buffer; |
|
68 |
|
69 VA_LIST list; |
|
70 VA_START( list, aFmt ); |
|
71 buffer.AppendFormatList( aFmt, list ); |
|
72 VA_END(list); |
|
73 |
|
74 FU_DEBUG(_L("#Fu# %S"), &buffer ); |
|
75 } |
|
76 }; |
|
77 |
|
78 class TMpxLog : public TDes16Overflow |
|
79 { |
|
80 public: |
|
81 |
|
82 inline static void MpxLog( TRefByValue<const TDesC16> aFmt, ... ) |
|
83 { |
|
84 TBuf< 512 > buffer; |
|
85 |
|
86 VA_LIST list; |
|
87 VA_START( list, aFmt ); |
|
88 buffer.AppendFormatList( aFmt, list ); |
|
89 VA_END(list); |
|
90 |
|
91 FU_DEBUG(_L("#Mpx# %S"), &buffer ); |
|
92 } |
|
93 }; |
|
94 |
|
95 #define MPX_DEBUG TMpxLog::MpxLog |
|
96 #define MPX_DEBUG1(s) MPX_DEBUG(_L(#s)) |
|
97 #define MPX_DEBUG2(s, a) MPX_DEBUG(_L(#s), a) |
|
98 #define MPX_DEBUG3(s, a, b) MPX_DEBUG(_L(#s), a, b) |
|
99 #define MPX_DEBUG4(s, a, b, c) MPX_DEBUG(_L(#s), a, b, c) |
|
100 #define MPX_DEBUG5(s, a, b, c, d) MPX_DEBUG(_L(#s), a, b, c, d) |
|
101 |
|
102 class TFunctionTrace |
|
103 { |
|
104 public: |
|
105 TFunctionTrace(TRefByValue<const TDesC> aName, TAny* aThis=NULL): |
|
106 iStr(aName), iThis(aThis) |
|
107 { |
|
108 //iThis ? MPX_DEBUG3("-->%S, 0x%08x",&iStr, iThis) : MPX_DEBUG2("-->%S",&iStr); |
|
109 iThis ? MPX_DEBUG(_L("-->%S, 0x%08x"),&iStr, iThis) : MPX_DEBUG(_L("-->%S"),&iStr); |
|
110 } |
|
111 ~TFunctionTrace() |
|
112 { |
|
113 //iThis ? MPX_DEBUG3("<--%S, 0x%08x",&iStr, iThis) : MPX_DEBUG2("<--%S",&iStr); |
|
114 iThis ? MPX_DEBUG(_L("<--%S, 0x%08x"),&iStr, iThis) : MPX_DEBUG(_L("<--%S"),&iStr); |
|
115 } |
|
116 private: |
|
117 TPtrC iStr; |
|
118 TAny* iThis; |
|
119 }; |
|
120 |
|
121 class TEnterExitLog : public TDes16Overflow |
|
122 { |
|
123 public: |
|
124 |
|
125 void Overflow(TDes16& /*aDes*/) |
|
126 { |
|
127 FU_DEBUG(_L("%S Logging Overflow"), &iFunctionName); |
|
128 } |
|
129 |
|
130 TEnterExitLog( TRefByValue<const TDesC> aFunctionName, |
|
131 TRefByValue<const TDesC> aFmt, ... ) |
|
132 { |
|
133 iFunctionName = HBufC::New( TDesC(aFunctionName).Length() ); |
|
134 |
|
135 if ( iFunctionName ) |
|
136 { |
|
137 iFunctionName->Des().Copy(aFunctionName); |
|
138 } |
|
139 |
|
140 TBuf< 512 > buffer; |
|
141 |
|
142 VA_LIST list; |
|
143 VA_START( list, aFmt ); |
|
144 buffer.AppendFormatList( aFmt, list, this ); |
|
145 VA_END(list); |
|
146 |
|
147 FU_DEBUG(_L("#Fu# --> %S %S"), iFunctionName, &buffer ); |
|
148 } |
|
149 |
|
150 TEnterExitLog( TRefByValue<const TDesC> aFunctionName ) |
|
151 { |
|
152 iFunctionName = HBufC::New( TDesC(aFunctionName).Length() ); |
|
153 |
|
154 if ( iFunctionName ) |
|
155 { |
|
156 iFunctionName->Des().Copy(aFunctionName); |
|
157 } |
|
158 |
|
159 FU_DEBUG(_L("#Fu# --> %S"), iFunctionName ); |
|
160 } |
|
161 |
|
162 ~TEnterExitLog() |
|
163 { |
|
164 FU_DEBUG(_L("#Fu# <-- %S"), iFunctionName ); |
|
165 delete iFunctionName; |
|
166 } |
|
167 |
|
168 private: |
|
169 HBufC* iFunctionName; |
|
170 }; |
|
171 |
|
172 _LIT(_KMPXErrorInfo, "#Fu# MPXVideo Error : error %d file %s line %d"); |
|
173 |
|
174 #define MPX_S(a) _S(a) |
|
175 |
|
176 #define MPX_ERROR_LOG(aErr) \ |
|
177 {\ |
|
178 if (aErr) \ |
|
179 FU_DEBUG(_KMPXErrorInfo, aErr, MPX_S(__FILE__), __LINE__);\ |
|
180 } |
|
181 |
|
182 #define MPX_TRAP(_r, _s) TRAP(_r,_s);MPX_ERROR_LOG(_r); |
|
183 #define MPX_TRAPD(_r, _s) TRAPD(_r,_s);MPX_ERROR_LOG(_r); |
|
184 |
|
185 /////////////////////////////////////////////////// |
|
186 #else // UREL VERSION STARTS HERE |
|
187 /////////////////////////////////////////////////// |
|
188 |
|
189 #define FU_DEBUG |
|
190 |
|
191 // MACROS |
|
192 #define MPX_ENTER_EXIT |
|
193 |
|
194 #define MPX_DEBUG |
|
195 #define MPX_DEBUG1(s) |
|
196 #define MPX_DEBUG2(s, a) |
|
197 #define MPX_DEBUG3(s, a, b) |
|
198 #define MPX_DEBUG4(s, a, b, c) |
|
199 #define MPX_DEBUG5(s, a, b, c, d) |
|
200 |
|
201 #define MPX_S(a) |
|
202 |
|
203 #define MPX_ERROR_LOG(aErr) |
|
204 |
|
205 #define MPX_TRAP(_r, _s) TRAP(_r,_s); |
|
206 #define MPX_TRAPD(_r, _s) TRAPD(_r,_s); |
|
207 |
|
208 #endif // _DEBUG |
|
209 |
|
210 #endif // __MPXVIDEO_DEBUG_H__ |
|
211 |
|
212 // End of File |