|
1 /* |
|
2 * Copyright (c) 2007 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: This is class is for logging purposes. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _CCALOGGER_H |
|
20 #define _CCALOGGER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 // logging is done only in debug |
|
25 #ifdef _DEBUG |
|
26 #include <flogger.h> |
|
27 #include <e32debug.h> |
|
28 |
|
29 //Logging constants |
|
30 _LIT(KLogDir, "cca"); |
|
31 |
|
32 #define CCA_L(s) _L(s) |
|
33 #define CCA_L8(s) _L8(s) |
|
34 |
|
35 #define CCA_DP CCADebugWriteFormat |
|
36 |
|
37 |
|
38 /** |
|
39 * Log file printing utility function |
|
40 * @since Series 60 v5.0 |
|
41 */ |
|
42 inline void CCADebugWriteFormat( TRefByValue<const TDesC> aFile, TRefByValue<const TDesC> aFmt,...) //lint !e960 |
|
43 { |
|
44 |
|
45 TBuf< 256 > buffer; |
|
46 |
|
47 { |
|
48 VA_LIST list; |
|
49 VA_START (list, aFmt); //lint !e960 |
|
50 TBuf< 300 > formatted; |
|
51 formatted.FormatList( aFmt, list ); |
|
52 buffer.Append( formatted.Left( buffer.MaxLength() - buffer.Length() ) ); |
|
53 } |
|
54 |
|
55 RFileLogger::Write( KLogDir, aFile, EFileLoggingModeAppend, buffer ); |
|
56 RDebug::RawPrint(buffer); |
|
57 |
|
58 } |
|
59 |
|
60 /** |
|
61 * Log file printing utility function |
|
62 * @since Series 60 v5.0 |
|
63 */ |
|
64 |
|
65 inline void CCADebugWriteFormat( TRefByValue<const TDesC> aFile, TRefByValue<const TDesC8> aFmt,...) //lint !e960 |
|
66 { |
|
67 TBuf8< 256 > buffer; |
|
68 { |
|
69 VA_LIST list; |
|
70 VA_START (list, aFmt); //lint !e960 |
|
71 TBuf8< 300 > formatted; |
|
72 formatted.FormatList( aFmt, list ); |
|
73 buffer.Append( formatted.Left( buffer.MaxLength() - buffer.Length() ) ); |
|
74 } |
|
75 RFileLogger::Write( KLogDir, aFile, EFileLoggingModeAppend, buffer ); |
|
76 RDebug::RawPrint(buffer); |
|
77 } |
|
78 |
|
79 |
|
80 #else // _DEBUG |
|
81 |
|
82 struct TCCAEmptyDebugString { }; |
|
83 |
|
84 #define CCA_L(s) TCCAEmptyDebugString() |
|
85 #define CCA_L8(s) TCCAEmptyDebugString() |
|
86 |
|
87 /// Empty debug print function for release builds. |
|
88 inline void CCA_DP(TCCAEmptyDebugString) |
|
89 { |
|
90 } |
|
91 |
|
92 template<class T1> |
|
93 inline void CCA_DP(TCCAEmptyDebugString,T1) |
|
94 { |
|
95 } |
|
96 |
|
97 template<class T1,class T2> |
|
98 inline void CCA_DP(TCCAEmptyDebugString,T1,T2) |
|
99 { |
|
100 } |
|
101 |
|
102 template<class T1,class T2,class T3> |
|
103 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3) |
|
104 { |
|
105 } |
|
106 |
|
107 template<class T1,class T2,class T3,class T4> |
|
108 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4) |
|
109 { |
|
110 } |
|
111 |
|
112 template<class T1,class T2,class T3,class T4,class T5> |
|
113 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5) |
|
114 { |
|
115 } |
|
116 |
|
117 template<class T1,class T2,class T3,class T4,class T5,class T6> |
|
118 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5,T6) |
|
119 { |
|
120 } |
|
121 |
|
122 template<class T1,class T2,class T3,class T4,class T5,class T6,class T7> |
|
123 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5,T6,T7) |
|
124 { |
|
125 } |
|
126 |
|
127 template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8> |
|
128 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5,T6,T7,T8) |
|
129 { |
|
130 } |
|
131 |
|
132 #endif // _DEBUG |
|
133 |
|
134 |
|
135 /** |
|
136 * PERFORMANCE LOGGINS |
|
137 * |
|
138 * OPTIONS: |
|
139 * PERF_LOGGING -> 12 different points where performance is measured. (c:\logs\perflogger.txt) |
|
140 * http://presenceprojects/trac/wiki/PerfLogging |
|
141 * |
|
142 * PERF_LAUNCH -> For test guys (c:\logs\perflaunch.txt) |
|
143 * |
|
144 */ |
|
145 |
|
146 #undef PERF_LOGGING |
|
147 #define PERF_LAUNCH |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 #ifdef PERF_LOGGING |
|
153 #include <flogger.h> |
|
154 |
|
155 _LIT( KPerfLogDir, "cca" ); |
|
156 _LIT( KPerfLogFile, "perflogger.txt" ); |
|
157 |
|
158 #define CCA_PERF WriteToPerfLog |
|
159 |
|
160 inline void WriteToPerfLog( ) |
|
161 { |
|
162 TBuf<30> dateString; |
|
163 TTime time; |
|
164 time.HomeTime(); |
|
165 _LIT(KDateString,"%-B%:0%J%:1%T%:2%S%.%*C4"); |
|
166 time.FormatL(dateString,KDateString); |
|
167 |
|
168 RFileLogger::Write( KPerfLogDir, KPerfLogFile, EFileLoggingModeAppend, dateString ); |
|
169 } |
|
170 |
|
171 #else // PERF_LOGGING |
|
172 |
|
173 inline void WriteToPerfLog( ) |
|
174 { |
|
175 } |
|
176 |
|
177 #endif // PERF_LOGGING |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 #ifdef PERF_LAUNCH |
|
183 #include <flogger.h> |
|
184 |
|
185 _LIT( KPerfLaunchLogDir, "cca" ); |
|
186 _LIT( KPerfLaunchLogFile, "perflaunch.txt" ); |
|
187 _LIT( KPerfLaunchLogTimeFormatString, "%T:%S:%*C4" ); |
|
188 |
|
189 inline void WriteToPerfLaunchLog( const TDesC& aText ) |
|
190 { |
|
191 TBuf<30> dateString; |
|
192 TTime time; |
|
193 time.HomeTime(); |
|
194 time.FormatL(dateString,KPerfLaunchLogTimeFormatString); |
|
195 dateString.Append(aText); |
|
196 RFileLogger::Write( KPerfLaunchLogDir, KPerfLaunchLogFile, EFileLoggingModeAppend, dateString ); |
|
197 } |
|
198 |
|
199 |
|
200 #else // PERF_LAUNCH |
|
201 |
|
202 inline void WriteToPerfLaunchLog( const TDesC& /*aText*/ ) |
|
203 { |
|
204 } |
|
205 |
|
206 |
|
207 #endif // PERF_LAUNCH |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 #endif // _CCALOGGER_H |
|
216 |
|
217 // End of File |