|
1 /* |
|
2 * Copyright (c) 2008-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: Defines trace macros |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef APPMNGR2DEBUGCONFIG_H |
|
20 #define APPMNGR2DEBUGCONFIG_H |
|
21 |
|
22 #ifdef _DEBUG |
|
23 |
|
24 |
|
25 /* --------------------------------------------------------------------------- |
|
26 * Enable/disable traces |
|
27 * --------------------------------------------------------------------------- |
|
28 * Uncomment one of the following macros to enable tracing: |
|
29 */ |
|
30 //#define PRINT_FLOG_TO_RDEBUG |
|
31 //#define PRINT_FLOG_TO_UTRACE |
|
32 //#define PRINT_FLOG_TO_FLOGGER |
|
33 /* |
|
34 * Select the trace type by uncommenting FLOG_DEBUG_TRACES or |
|
35 * FLOG_PERFORMANCE_TRACES (or both) below. |
|
36 * |
|
37 * Note that also SYMBIAN_TRACE_ENABLE must be defined in order |
|
38 * to use PRINT_FLOG_TO_UTRACE. |
|
39 */ |
|
40 |
|
41 |
|
42 /* --------------------------------------------------------------------------- |
|
43 * Debug traces |
|
44 * --------------------------------------------------------------------------- |
|
45 * Uncomment the following line to enable debug traces: |
|
46 */ |
|
47 //#define FLOG_DEBUG_TRACES |
|
48 /* |
|
49 * Debug traces are generated using FLOG macro. FLOG takes a format |
|
50 * string and variable number of arguments, like TDes::Format(). Except |
|
51 * that format string "x" is replaced with string literal _L("x"), so |
|
52 * string literal _L() should not be used when calling FLOG. |
|
53 * |
|
54 * Examples: |
|
55 * FLOG( "CAppMngr2AppUi::ConstructL" ); |
|
56 * FLOG( "CAppMngr2AppUi::HandleCommandL( %d )", aCommand ); |
|
57 * FLOG( "Scanning %d: %S", iIndex, &iDirName ) ); |
|
58 */ |
|
59 |
|
60 |
|
61 /* --------------------------------------------------------------------------- |
|
62 * Performance traces |
|
63 * --------------------------------------------------------------------------- |
|
64 * Uncomment the following line to enable performance traces: |
|
65 */ |
|
66 //#define FLOG_PERFORMANCE_TRACES |
|
67 /* |
|
68 * Performance traces measure and print times that different |
|
69 * code fragments take (in milliseconds). Please note that |
|
70 * printing traces is usually slow and this may affect to the |
|
71 * results if debug or other performance traces are printed |
|
72 * out from the timed functions. |
|
73 * |
|
74 * There are two sets of performance tracing macros: static and |
|
75 * dynamic. Parameter is used to match corresponding macros and |
|
76 * it is also printed in trace output. Macros use temporary TTime |
|
77 * variables, hence macros (using the same parameter label) must |
|
78 * be in the same scope. |
|
79 * |
|
80 * The macros are: |
|
81 * FLOG_PERF_STATIC_BEGIN - records start time |
|
82 * FLOG_PERF_STATIC_END - records end time and prints results |
|
83 * FLOG_PERF_DEFINE - defines temporary variables |
|
84 * FLOG_PERF_START - records start time (fast) |
|
85 * FLOG_PERF_STOP - records end time (fast) |
|
86 * FLOG_PERF_PRINT - prints out the results (slow) |
|
87 * |
|
88 * Examples: |
|
89 * FLOG_PERF_STATIC_BEGIN( LoadPluginsL ) |
|
90 * LoadPluginsL(); |
|
91 * FLOG_PERF_STATIC_END( LoadPluginsL ) |
|
92 * FLOG_PERF_STATIC_BEGIN( CreateScannerL ) |
|
93 * CreateScannerL(); |
|
94 * FLOG_PERF_STATIC_END( CreateScannerL ) |
|
95 * FLOG_PERF_STATIC_BEGIN( FetchDataTypesL ) |
|
96 * FetchDataTypesL(); |
|
97 * FLOG_PERF_STATIC_END( FetchDataTypesL ) |
|
98 * |
|
99 * This generates traces like: |
|
100 * AppMngr2: PERF LoadPluginsL: 157 ms |
|
101 * AppMngr2: PERF CreateScannerL: 8 ms |
|
102 * AppMngr2: PERF FetchDataTypesL: 2 ms |
|
103 * |
|
104 * Dynamic macros do the same thing as static macros, but possibly |
|
105 * slow parts (that may affect to results) are put into separate |
|
106 * FLOG_PERF_DEFINE and FLOG_PERF_PRINT macros. Printing the trace |
|
107 * is usually slow, which may affect to results (e.g. if static |
|
108 * macros are nested). Dynamic macros can be used to measure run |
|
109 * times of active objects too. |
|
110 * |
|
111 * Semicolons are not needed after FLOG macros. Semicolons can be |
|
112 * used, but they may issue "illegal empty declaration" warning |
|
113 * after FLOG_PERF_DEFINE() macros when traces are disabled. |
|
114 */ |
|
115 |
|
116 |
|
117 // Sanity check: each FLOG macro produces compilation error if |
|
118 // PRINT_FLOG_TO_UTRACE is defined but SYMBIAN_TRACE_ENABLE is not. |
|
119 #if( defined( PRINT_FLOG_TO_UTRACE ) && !defined( SYMBIAN_TRACE_ENABLE ) ) |
|
120 #error "SYMBIAN_TRACE_ENABLE not defined, PRINT_FLOG_TO_UTRACE needs it." |
|
121 #endif |
|
122 |
|
123 // Sanity check: traces can be printed to only one target (RDebug, UTrace, or FLogger) |
|
124 #if( defined( PRINT_FLOG_TO_RDEBUG ) && defined( PRINT_FLOG_TO_UTRACE ) ) |
|
125 #error "Cannot define both PRINT_FLOG_TO_RDEBUG and PRINT_FLOG_TO_UTRACE macros." |
|
126 #endif |
|
127 #if( defined( PRINT_FLOG_TO_RDEBUG ) && defined( PRINT_FLOG_TO_FLOGGER ) ) |
|
128 #error "Cannot define both PRINT_FLOG_TO_RDEBUG and PRINT_FLOG_TO_FLOGGER macros." |
|
129 #endif |
|
130 #if( defined( PRINT_FLOG_TO_UTRACE ) && defined( PRINT_FLOG_TO_FLOGGER ) ) |
|
131 #error "Cannot define both PRINT_FLOG_TO_UTRACE and PRINT_FLOG_TO_FLOGGER macros." |
|
132 #endif |
|
133 |
|
134 // Sanity check: when traces are enabled, also trace type must be selected. |
|
135 #if( defined( PRINT_FLOG_TO_RDEBUG ) || defined( PRINT_FLOG_TO_UTRACE ) || defined( PRINT_FLOG_TO_FLOGGER ) ) |
|
136 #define FLOG_TRACES_ENABLED |
|
137 #endif |
|
138 #if( defined( FLOG_TRACES_ENABLED ) ) |
|
139 #if( !defined( FLOG_DEBUG_TRACES ) && !defined( FLOG_PERFORMANCE_TRACES ) ) |
|
140 #error "Traces enabled but FLOG_DEBUG_TRACES or FLOG_PERFORMANCE_TRACES is not defined." |
|
141 #endif |
|
142 #endif |
|
143 |
|
144 #endif // _DEBUG |
|
145 |
|
146 #endif // APPMNGR2DEBUGCONFIG_H |
|
147 |