|
1 /* |
|
2 * Copyright (c) 2008 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 the License "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 // Version : %version: ou1cpsw#3 % |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef __MPXVIDEO_DEBUG_H__ |
|
24 #define __MPXVIDEO_DEBUG_H__ |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32std.h> |
|
28 #include <e32svr.h> |
|
29 #include <e32des16.h> |
|
30 #include <e32property.h> |
|
31 #include <flogger.h> |
|
32 #include <e32def.h> |
|
33 |
|
34 |
|
35 |
|
36 // #define _MPX_FILE_LOGGING_ |
|
37 |
|
38 #ifdef _DEBUG |
|
39 #define FU_DEBUG RDebug::Print |
|
40 #else |
|
41 #ifdef _MPX_FILE_LOGGING_ |
|
42 #define FU_DEBUG MPXDebug::FileLog |
|
43 #else |
|
44 #define FU_DEBUG MPXDebug::NullLog |
|
45 #endif |
|
46 #endif |
|
47 |
|
48 |
|
49 class MPXDebug |
|
50 { |
|
51 public: |
|
52 inline static void NullLog( TRefByValue<const TDesC16> /*aFmt*/, ... ) |
|
53 { |
|
54 } |
|
55 |
|
56 inline static void NullLog( TRefByValue<const TDesC> /*aFunctionName*/, |
|
57 TRefByValue<const TDesC16> /*aFmt*/, ... ) |
|
58 { |
|
59 } |
|
60 |
|
61 inline static void FileLog( TRefByValue<const TDesC16> aFmt, ... ) |
|
62 { |
|
63 VA_LIST list; |
|
64 VA_START(list,aFmt); |
|
65 RFileLogger::WriteFormat( _L("Fusion"), |
|
66 _L("fusion.log"), |
|
67 EFileLoggingModeAppend, |
|
68 aFmt, |
|
69 list ); |
|
70 } |
|
71 }; |
|
72 |
|
73 |
|
74 |
|
75 // MACROS |
|
76 #ifdef _DEBUG |
|
77 #define MPX_DEBUG TFusionLog::FusionLog |
|
78 #define MPX_ENTER_EXIT TEnterExitLog _s |
|
79 #else |
|
80 #define MPX_DEBUG MPXDebug::NullLog |
|
81 #define MPX_ENTER_EXIT MPXDebug::NullLog |
|
82 #endif |
|
83 |
|
84 |
|
85 class TFusionLog : public TDes16Overflow |
|
86 { |
|
87 public: |
|
88 |
|
89 inline static void FusionLog( TRefByValue<const TDesC16> aFmt, ... ) |
|
90 { |
|
91 TBuf< 512 > buffer; |
|
92 |
|
93 VA_LIST list; |
|
94 VA_START( list, aFmt ); |
|
95 buffer.AppendFormatList( aFmt, list ); |
|
96 VA_END(list); |
|
97 |
|
98 FU_DEBUG(_L("#Fu# %S"), &buffer ); |
|
99 } |
|
100 }; |
|
101 |
|
102 class TEnterExitLog : public TDes16Overflow |
|
103 { |
|
104 public: |
|
105 |
|
106 void Overflow(TDes16& /*aDes*/) |
|
107 { |
|
108 FU_DEBUG(_L("%S Logging Overflow"), &iFunctionName); |
|
109 } |
|
110 |
|
111 TEnterExitLog( TRefByValue<const TDesC> aFunctionName, |
|
112 TRefByValue<const TDesC> aFmt, ... ) |
|
113 { |
|
114 iFunctionName = HBufC::New( TDesC(aFunctionName).Length() ); |
|
115 |
|
116 if ( iFunctionName ) |
|
117 { |
|
118 iFunctionName->Des().Copy(aFunctionName); |
|
119 } |
|
120 |
|
121 TBuf< 512 > buffer; |
|
122 |
|
123 VA_LIST list; |
|
124 VA_START( list, aFmt ); |
|
125 buffer.AppendFormatList( aFmt, list, this ); |
|
126 VA_END(list); |
|
127 |
|
128 FU_DEBUG(_L("#Fu# --> %S %S"), iFunctionName, &buffer ); |
|
129 } |
|
130 |
|
131 TEnterExitLog( TRefByValue<const TDesC> aFunctionName ) |
|
132 { |
|
133 iFunctionName = HBufC::New( TDesC(aFunctionName).Length() ); |
|
134 |
|
135 if ( iFunctionName ) |
|
136 { |
|
137 iFunctionName->Des().Copy(aFunctionName); |
|
138 } |
|
139 |
|
140 FU_DEBUG(_L("#Fu# --> %S"), iFunctionName ); |
|
141 } |
|
142 |
|
143 ~TEnterExitLog() |
|
144 { |
|
145 FU_DEBUG(_L("#Fu# <-- %S"), iFunctionName ); |
|
146 delete iFunctionName; |
|
147 } |
|
148 |
|
149 private: |
|
150 HBufC* iFunctionName; |
|
151 }; |
|
152 |
|
153 _LIT(_KMPXErrorInfo, "#Fu# MPXVideo Error : error %d file %s line %d"); |
|
154 |
|
155 #define MPX_S(a) _S(a) |
|
156 |
|
157 #define MPX_ERROR_LOG(aErr) \ |
|
158 {\ |
|
159 if (aErr) \ |
|
160 FU_DEBUG(_KMPXErrorInfo, aErr, MPX_S(__FILE__), __LINE__);\ |
|
161 } |
|
162 |
|
163 #define MPX_TRAP(_r, _s) TRAP(_r,_s);MPX_ERROR_LOG(_r); |
|
164 #define MPX_TRAPD(_r, _s) TRAPD(_r,_s);MPX_ERROR_LOG(_r); |
|
165 |
|
166 #endif // __MPXVIDEO_DEBUG_H__ |
|
167 |
|
168 // End of File |