|
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 // logging is done only in debug |
|
23 #ifdef _DEBUG |
|
24 #include <flogger.h> |
|
25 #include <e32debug.h> |
|
26 |
|
27 //Logging constants |
|
28 _LIT(KLogDir, "cca"); |
|
29 |
|
30 #define CCA_L(s) _L(s) |
|
31 #define CCA_L8(s) _L8(s) |
|
32 |
|
33 #define CCA_DP CCADebugWriteFormat |
|
34 |
|
35 |
|
36 /** |
|
37 * Log file printing utility function |
|
38 * @since Series 60 v5.0 |
|
39 */ |
|
40 inline void CCADebugWriteFormat( TRefByValue<const TDesC> aFile, TRefByValue<const TDesC> aFmt,...) //lint !e960 |
|
41 { |
|
42 |
|
43 TBuf< 256 > buffer; |
|
44 |
|
45 { |
|
46 VA_LIST list; |
|
47 VA_START (list, aFmt); //lint !e960 |
|
48 TBuf< 300 > formatted; |
|
49 formatted.FormatList( aFmt, list ); |
|
50 buffer.Append( formatted.Left( buffer.MaxLength() - buffer.Length() ) ); |
|
51 } |
|
52 |
|
53 RFileLogger::Write( KLogDir, aFile, EFileLoggingModeAppend, buffer ); |
|
54 RDebug::RawPrint(buffer); |
|
55 |
|
56 } |
|
57 |
|
58 /** |
|
59 * Log file printing utility function |
|
60 * @since Series 60 v5.0 |
|
61 */ |
|
62 |
|
63 inline void CCADebugWriteFormat( TRefByValue<const TDesC> aFile, TRefByValue<const TDesC8> aFmt,...) //lint !e960 |
|
64 { |
|
65 TBuf8< 256 > buffer; |
|
66 { |
|
67 VA_LIST list; |
|
68 VA_START (list, aFmt); //lint !e960 |
|
69 TBuf8< 300 > formatted; |
|
70 formatted.FormatList( aFmt, list ); |
|
71 buffer.Append( formatted.Left( buffer.MaxLength() - buffer.Length() ) ); |
|
72 } |
|
73 RFileLogger::Write( KLogDir, aFile, EFileLoggingModeAppend, buffer ); |
|
74 RDebug::RawPrint(buffer); |
|
75 } |
|
76 |
|
77 |
|
78 #else // _DEBUG |
|
79 |
|
80 struct TCCAEmptyDebugString { }; |
|
81 |
|
82 #define CCA_L(s) TCCAEmptyDebugString() |
|
83 #define CCA_L8(s) TCCAEmptyDebugString() |
|
84 |
|
85 /// Empty debug print function for release builds. |
|
86 inline void CCA_DP(TCCAEmptyDebugString) |
|
87 { |
|
88 } |
|
89 |
|
90 template<class T1> |
|
91 inline void CCA_DP(TCCAEmptyDebugString,T1) |
|
92 { |
|
93 } |
|
94 |
|
95 template<class T1,class T2> |
|
96 inline void CCA_DP(TCCAEmptyDebugString,T1,T2) |
|
97 { |
|
98 } |
|
99 |
|
100 template<class T1,class T2,class T3> |
|
101 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3) |
|
102 { |
|
103 } |
|
104 |
|
105 template<class T1,class T2,class T3,class T4> |
|
106 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4) |
|
107 { |
|
108 } |
|
109 |
|
110 template<class T1,class T2,class T3,class T4,class T5> |
|
111 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5) |
|
112 { |
|
113 } |
|
114 |
|
115 template<class T1,class T2,class T3,class T4,class T5,class T6> |
|
116 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5,T6) |
|
117 { |
|
118 } |
|
119 |
|
120 template<class T1,class T2,class T3,class T4,class T5,class T6,class T7> |
|
121 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5,T6,T7) |
|
122 { |
|
123 } |
|
124 |
|
125 template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8> |
|
126 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5,T6,T7,T8) |
|
127 { |
|
128 } |
|
129 |
|
130 #endif // _DEBUG |
|
131 |
|
132 //TODO: Change |
|
133 #define PERF_LOGGING |
|
134 |
|
135 #ifdef PERF_LOGGING |
|
136 #include <flogger.h> |
|
137 |
|
138 _LIT( KPerfLogDir, "cca" ); |
|
139 _LIT( KPerfLogFile, "performancelogger.txt" ); |
|
140 |
|
141 #define CCA_PERF WriteToPerfLog |
|
142 |
|
143 inline void WriteToPerfLog( ) |
|
144 { |
|
145 TBuf<30> dateString; |
|
146 TTime time; |
|
147 time.HomeTime(); |
|
148 _LIT(KDateString,"%-B%:0%J%:1%T%:2%S%.%*C4"); |
|
149 time.FormatL(dateString,KDateString); |
|
150 |
|
151 RFileLogger::Write( KPerfLogDir, KPerfLogFile, EFileLoggingModeAppend, dateString ); |
|
152 } |
|
153 |
|
154 #endif // PERF_LOGGING |
|
155 |
|
156 |
|
157 #endif // _CCALOGGER_H |
|
158 |
|
159 // End of File |