|
1 /* |
|
2 * Copyright (c) 2002 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 macros |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MGDEBUGPRINT_H__ |
|
20 #define __MGDEBUGPRINT_H__ |
|
21 |
|
22 #include "harvesterlog.h" |
|
23 |
|
24 #ifdef _DEBUG |
|
25 #define MG_ENABLE_DEBUG_PRINT |
|
26 #endif |
|
27 |
|
28 // Debug logging is enabled, you may enable debug printing in release builds also |
|
29 #ifdef MG_ENABLE_DEBUG_PRINT |
|
30 |
|
31 // warn if this is a release build!! |
|
32 #ifndef __WINSCW__ |
|
33 #ifndef _DEBUG |
|
34 #if defined(__VC32__) |
|
35 #pragma message( "Warning: MG debug printing is on in release build!" ) // CSI: 68 # 68:use of #pragma message |
|
36 #else // __GCC32__ |
|
37 #warning "MG debug printing is on in release build!" |
|
38 #endif // __VC32__ |
|
39 #endif |
|
40 #endif // __WINSCW__ |
|
41 |
|
42 // no include files if no debug printing --> faster compile time |
|
43 // INCLUDES |
|
44 #include <e32std.h> |
|
45 #include <e32svr.h> |
|
46 |
|
47 /** |
|
48 * Helper macro for defining debug strings with just the debug text. |
|
49 */ |
|
50 #define MG_DEBUG_STRING(name,s) _LIT(name,s) |
|
51 |
|
52 /** |
|
53 * Output to debugger output |
|
54 */ |
|
55 #define MG_DEBUG_PRINT RDebug::Print |
|
56 |
|
57 #else // MG_ENABLE_DEBUG_PRINT |
|
58 |
|
59 /** |
|
60 * Dummy struct for checking that all MG_DEBUG_PRINT's define string |
|
61 * literals using space-saving MG_DEBUG_STRING. |
|
62 */ |
|
63 struct TMGEmptyDebugString { }; // CSI: 80 # 80:use of struct |
|
64 |
|
65 /** |
|
66 * Macro for defining debug-only literal strings (empty release version) |
|
67 */ |
|
68 #define MG_DEBUG_STRING(name, s) const TMGEmptyDebugString name |
|
69 |
|
70 /** |
|
71 * Output to debugger output (empty) |
|
72 */ |
|
73 #define MG_DEBUG_PRINT MG_EmptyPrint |
|
74 |
|
75 /// Empty debug print function for release builds. |
|
76 inline void MG_EmptyPrint(TMGEmptyDebugString) |
|
77 { |
|
78 } |
|
79 |
|
80 /// Empty debug print function for release builds. |
|
81 template<class T1> |
|
82 inline void MG_EmptyPrint(TMGEmptyDebugString,T1) |
|
83 { |
|
84 } |
|
85 |
|
86 /// Empty debug print function for release builds. |
|
87 template<class T1,class T2> |
|
88 inline void MG_EmptyPrint(TMGEmptyDebugString,T1,T2) |
|
89 { |
|
90 } |
|
91 |
|
92 /// Empty debug print function for release builds. |
|
93 template<class T1,class T2,class T3> |
|
94 inline void MG_EmptyPrint(TMGEmptyDebugString,T1,T2,T3) |
|
95 { |
|
96 } |
|
97 |
|
98 /// Empty debug print function for release builds. |
|
99 template<class T1,class T2,class T3,class T4> |
|
100 inline void MG_EmptyPrint(TMGEmptyDebugString,T1,T2,T3,T4) |
|
101 { |
|
102 } |
|
103 |
|
104 /// Empty debug print function for release builds. |
|
105 template<class T1,class T2,class T3,class T4,class T5> |
|
106 inline void MG_EmptyPrint(TMGEmptyDebugString,T1,T2,T3,T4,T5) |
|
107 { |
|
108 } |
|
109 |
|
110 /// Empty debug print function for release builds. |
|
111 template<class T1,class T2,class T3,class T4,class T5,class T6> |
|
112 inline void MG_EmptyPrint(TMGEmptyDebugString,T1,T2,T3,T4,T5,T6) |
|
113 { |
|
114 } |
|
115 |
|
116 /// Empty debug print function for release builds. |
|
117 template<class T1,class T2,class T3,class T4,class T5,class T6,class T7> |
|
118 inline void MG_EmptyPrint(TMGEmptyDebugString,T1,T2,T3,T4,T5,T6,T7) |
|
119 { |
|
120 } |
|
121 |
|
122 /// Empty debug print function for release builds. |
|
123 template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8> |
|
124 inline void MG_EmptyPrint(TMGEmptyDebugString,T1,T2,T3,T4,T5,T6,T7,T8) |
|
125 { |
|
126 } |
|
127 |
|
128 |
|
129 #endif // MG_ENABLE_DEBUG_PRINT |
|
130 |
|
131 /** |
|
132 * Short variant for easier basic usage. |
|
133 */ |
|
134 #define MG_DEBUG1( name, s ) MG_DEBUG_STRING( name, s ); MG_DEBUG_PRINT( name ); |
|
135 |
|
136 #ifdef MG_ENABLE_DEBUG_PRINT |
|
137 #define MG_DEBUG2( name, s, i ) MG_DEBUG_STRING( name, s ); MG_DEBUG_PRINT( name, i ); |
|
138 #define MG_DEBUG3( name, s, i, j ) MG_DEBUG_STRING( name, s ); MG_DEBUG_PRINT( name, i, j ); |
|
139 #define MG_DEBUG4( name, s, i, j, k ) MG_DEBUG_STRING( name, s ); MG_DEBUG_PRINT( name, i, j, k ); |
|
140 #define MG_DEBUG5( name, s, i, j, k, l ) MG_DEBUG_STRING( name, s ); MG_DEBUG_PRINT( name, i, j, k, l ); |
|
141 #else |
|
142 // If debug printing is not enabled, strip other parameters than the string |
|
143 // away to prevent unwanted function calls in release build. |
|
144 #define MG_DEBUG2( name, s, i ) MG_DEBUG1( name, s ) |
|
145 #define MG_DEBUG3( name, s, i, j ) MG_DEBUG1( name, s ) |
|
146 #define MG_DEBUG4( name, s, i, j, k ) MG_DEBUG1( name, s ) |
|
147 #define MG_DEBUG5( name, s, i, j, k, l ) MG_DEBUG1( name, s ) |
|
148 #endif |
|
149 |
|
150 #endif // __MGDEBUGPRINT_H__ |