|
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 "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: Presence Cache trace utilities |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef PRESENCETRACE_H__ |
|
19 #define PRESENCETRACE_H__ |
|
20 |
|
21 #include <e32std.h> |
|
22 |
|
23 |
|
24 // CONSTANTS |
|
25 _LIT( KPresenceTraceLogDir, "presence" ); |
|
26 _LIT( KPresenceTraceLogFile, "presence.log" ); |
|
27 |
|
28 |
|
29 //TRACE INDIRECTION |
|
30 #ifdef _DEBUG |
|
31 |
|
32 /** |
|
33 * Trace handlers. Different statements with |
|
34 * different names for handling different parameter amounts. |
|
35 * |
|
36 * Link against ximpdatamodel.dll to use trace |
|
37 * services. |
|
38 * |
|
39 * Statements produce traces only in debug builds. |
|
40 * In hardware debug builds traces go to file defined |
|
41 * KPresenceTraceLogDir and KPresenceTraceLogFile. |
|
42 */ |
|
43 #define TRACE( aStatement ) PresenceTrace::Trace( aStatement ) |
|
44 #define TRACE_1( aStatement, aP1 ) PresenceTrace::Trace( aStatement, aP1 ) |
|
45 #define TRACE_2( aStatement, aP1, aP2 ) PresenceTrace::Trace( aStatement, aP1, aP2 ) |
|
46 #define TRACE_3( aStatement, aP1, aP2, aP3 ) PresenceTrace::Trace( aStatement, aP1, aP2, aP3 ) |
|
47 #define TRACE_4( aStatement, aP1, aP2, aP3, aP4 ) PresenceTrace::Trace( aStatement, aP1, aP2, aP3, aP4 ) |
|
48 #define TRACE_5( aStatement, aP1, aP2, aP3, aP4, aP5 ) PresenceTrace::Trace( aStatement, aP1, aP2, aP3, aP4, aP5 ) |
|
49 #define TRACE_6( aStatement, aP1, aP2, aP3, aP4, aP5, aP6 ) PresenceTrace::Trace( aStatement, aP1, aP2, aP3, aP4, aP5, aP6 ) |
|
50 |
|
51 |
|
52 /** |
|
53 * Block (and thus also function) trace handlers. These |
|
54 * mark block enter, exit and also non local exit to traces. |
|
55 * |
|
56 * Example: |
|
57 * void CSomeClass::SomeMethod() |
|
58 * { |
|
59 * TRACE_BLOCK_ENTER( "CSomeClass::SomeMethod" ); |
|
60 * |
|
61 * Do your stuff here. If there happens a leave |
|
62 * or return before "TRACE_BLOCK_EXIT()" statement, |
|
63 * it is marked to traces with "CSomeClass::SomeMethod - nonlocal exit" |
|
64 * |
|
65 * TRACE_BLOCK_EXIT(); |
|
66 * } |
|
67 */ |
|
68 #define TRACE_BLOCK_ENTER( aBlockName ) TPresenceBlockTraceHandler __blockTraceHandler( _S( aBlockName ) ); |
|
69 #define TRACE_BLOCK_EXIT() __blockTraceHandler.NormalExit(); |
|
70 |
|
71 |
|
72 |
|
73 #else //NOT _DEBUG |
|
74 |
|
75 #define TRACE( aStatement ) |
|
76 #define TRACE_1( aStatement, aP1 ) |
|
77 #define TRACE_2( aStatement, aP1, aP2 ) |
|
78 #define TRACE_3( aStatement, aP1, aP2, aP3 ) |
|
79 #define TRACE_4( aStatement, aP1, aP2, aP3, aP4 ) |
|
80 #define TRACE_5( aStatement, aP1, aP2, aP3, aP4, aP5 ) |
|
81 #define TRACE_6( aStatement, aP1, aP2, aP3, aP4, aP5, aP6 ) |
|
82 #define TRACE_BLOCK_ENTER( aBlockName ) |
|
83 #define TRACE_BLOCK_EXIT() |
|
84 |
|
85 #endif |
|
86 |
|
87 |
|
88 |
|
89 /** |
|
90 * XIMP Framework trace sink. |
|
91 * |
|
92 * @lib ximpdatamodel.dll |
|
93 * @since S60 v3.2 |
|
94 */ |
|
95 class PresenceTrace |
|
96 { |
|
97 public: |
|
98 |
|
99 /** |
|
100 * Trace sink. |
|
101 * |
|
102 * @param aFmt A format list to print to trace. |
|
103 */ |
|
104 IMPORT_C static void Trace( TRefByValue<const TDesC> aFmt,... ); |
|
105 |
|
106 |
|
107 |
|
108 private: //Prohibited construtor / destructor |
|
109 PresenceTrace(); |
|
110 ~PresenceTrace(); |
|
111 }; |
|
112 |
|
113 |
|
114 |
|
115 /** |
|
116 * Block trace handler. |
|
117 */ |
|
118 NONSHARABLE_CLASS( TPresenceBlockTraceHandler ) |
|
119 { |
|
120 public: |
|
121 |
|
122 /** |
|
123 * Block trace handler constructor. |
|
124 * |
|
125 * @param aBlockName Block name. |
|
126 */ |
|
127 TPresenceBlockTraceHandler( const TText* aBlockName ); |
|
128 |
|
129 |
|
130 /** |
|
131 * Block trace handler destructor. |
|
132 */ |
|
133 ~TPresenceBlockTraceHandler(); |
|
134 |
|
135 |
|
136 /** |
|
137 * Marks that block has reached its normal exit. |
|
138 */ |
|
139 void NormalExit(); |
|
140 |
|
141 |
|
142 private: |
|
143 //Block name |
|
144 const TPtrC iBlockName; |
|
145 |
|
146 //Normal exit marker |
|
147 TBool iBlockNormalExit; |
|
148 }; |
|
149 |
|
150 |
|
151 #endif // PresenceTrace_H__ |
|
152 |