|
1 /* |
|
2 * Copyright (c) 2002-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: Writes log entries for Connection Monitor Server. |
|
15 * |
|
16 * To take ConnMon logs, include the debug version of connmon.dll to rom image. |
|
17 * On the phone, create folder C:\logs\connmon. |
|
18 * |
|
19 */ |
|
20 |
|
21 #ifndef CONNECTIONMONITORLOG_H |
|
22 #define CONNECTIONMONITORLOG_H |
|
23 |
|
24 // Log output |
|
25 // 1 = RDebug |
|
26 // 2 = File |
|
27 #define _CONNMON_LOG_OUTPUT 2 |
|
28 |
|
29 #define _CONNMON_ENTEREXIT_LOGGING |
|
30 #define _CONNMON_FUNCTIONAL_LOGGING |
|
31 //#define _CONNMON_TIMING_LOGGING |
|
32 //#define _CONNMON_HEXDUMP_LOGGING // Only for file logging |
|
33 |
|
34 #include <e32std.h> |
|
35 #include <e32base.h> |
|
36 |
|
37 #if ( _CONNMON_LOG_OUTPUT == 1 ) |
|
38 #include <e32debug.h> |
|
39 #endif |
|
40 |
|
41 #ifdef _DEBUG |
|
42 |
|
43 #define LOG(a) a |
|
44 |
|
45 #ifdef _CONNMON_FUNCTIONAL_LOGGING |
|
46 #if ( _CONNMON_LOG_OUTPUT == 2 ) |
|
47 #define LOGIT(a) {_LIT(temp, a); Log::Printf(temp);} |
|
48 #define LOGIT1(a,a1) {_LIT(temp, a); Log::Printf(temp,a1);} |
|
49 #define LOGIT2(a,a1,a2) {_LIT(temp, a); Log::Printf(temp,a1,a2);} |
|
50 #define LOGIT3(a,a1,a2,a3) {_LIT(temp, a); Log::Printf(temp,a1,a2,a3);} |
|
51 #define LOGIT4(a,a1,a2,a3,a4) {_LIT(temp, a); Log::Printf(temp,a1,a2,a3,a4);} |
|
52 #define LOGIT5(a,a1,a2,a3,a4,a5) {_LIT(temp, a); Log::Printf(temp,a1,a2,a3,a4,a5);} |
|
53 #define LOGIT6(a,a1,a2,a3,a4,a5,a6) {_LIT(temp, a); Log::Printf(temp,a1,a2,a3,a4,a5,a6);} |
|
54 #define LOGIT11(a,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) {_LIT(temp, a); Log::Printf(temp,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11);} |
|
55 #else |
|
56 #define LOGIT(a) {_LIT(temp, a); RDebug::Print(temp);} |
|
57 #define LOGIT1(a,a1) {_LIT(temp, a); RDebug::Print(temp,a1);} |
|
58 #define LOGIT2(a,a1,a2) {_LIT(temp, a); RDebug::Print(temp,a1,a2);} |
|
59 #define LOGIT3(a,a1,a2,a3) {_LIT(temp, a); RDebug::Print(temp,a1,a2,a3);} |
|
60 #define LOGIT4(a,a1,a2,a3,a4) {_LIT(temp, a); RDebug::Print(temp,a1,a2,a3,a4);} |
|
61 #define LOGIT5(a,a1,a2,a3,a4,a5) {_LIT(temp, a); RDebug::Print(temp,a1,a2,a3,a4,a5);} |
|
62 #define LOGIT6(a,a1,a2,a3,a4,a5,a6) {_LIT(temp, a); RDebug::Print(temp,a1,a2,a3,a4,a5,a6);} |
|
63 #define LOGIT11(a,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) {_LIT(temp, a); RDebug::Print(temp,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11);} |
|
64 #endif |
|
65 #else |
|
66 #define LOGIT(a) |
|
67 #define LOGIT1(a,a1) |
|
68 #define LOGIT2(a,a1,a2) |
|
69 #define LOGIT3(a,a1,a2,a3) |
|
70 #define LOGIT4(a,a1,a2,a3,a4) |
|
71 #define LOGIT5(a,a1,a2,a3,a4,a5) |
|
72 #define LOGIT6(a,a1,a2,a3,a4,a5,a6) |
|
73 #define LOGIT11(a,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) |
|
74 #endif |
|
75 |
|
76 #ifdef _CONNMON_ENTEREXIT_LOGGING |
|
77 #if ( _CONNMON_LOG_OUTPUT == 2 ) |
|
78 _LIT(KConnMonLogEnterFn, "-> %S entered"); |
|
79 _LIT(KConnMonLogExitFn, "<- %S returned"); |
|
80 _LIT(KConnMonLogExitFn1, "<- %S returned <%d>"); |
|
81 #define LOGENTRFN(a) {_LIT(temp, a); Log::Printf(KConnMonLogEnterFn, &temp);} |
|
82 #define LOGEXITFN(a) {_LIT(temp, a); Log::Printf(KConnMonLogExitFn, &temp);} |
|
83 #define LOGEXITFN1(a,a1) {_LIT(temp, a); Log::Printf(KConnMonLogExitFn1, &temp, a1);} |
|
84 #else |
|
85 _LIT(KConnMonLogEnterFn, "ConnMon: -> %S entered"); |
|
86 _LIT(KConnMonLogExitFn, "ConnMon: <- %S returned"); |
|
87 _LIT(KConnMonLogExitFn1, "ConnMon: <- %S returned <%d>"); |
|
88 #define LOGENTRFN(a) {_LIT(temp, a); RDebug::Print(KConnMonLogEnterFn, &temp);} |
|
89 #define LOGEXITFN(a) {_LIT(temp, a); RDebug::Print(KConnMonLogExitFn, &temp);} |
|
90 #define LOGEXITFN1(a,a1) {_LIT(temp, a); RDebug::Print(KConnMonLogExitFn1, &temp, a1);} |
|
91 #endif |
|
92 #else |
|
93 #define LOGENTRFN(a) |
|
94 #define LOGEXITFN(a) |
|
95 #define LOGEXITFN1(a,a1) |
|
96 #endif |
|
97 |
|
98 #ifdef _CONNMON_TIMING_LOGGING |
|
99 #if ( _CONNMON_LOG_OUTPUT == 2 ) |
|
100 _LIT(KCMLogTimeStart, "TIMING: %S start"); |
|
101 _LIT(KCMLogTimeEnd, "TIMING: %S took %d ms"); |
|
102 #define LOGTIMINGSTART(a) \ |
|
103 {/*_LIT(s, a); Log::Printf(KCMLogTimeStart, &s);*/} \ |
|
104 TTime _connmon_start; \ |
|
105 TTime _connmon_end; \ |
|
106 TTimeIntervalMicroSeconds _connmon_dur; \ |
|
107 _connmon_start.UniversalTime(); |
|
108 |
|
109 #define LOGTIMINGEND(a) \ |
|
110 _connmon_end.UniversalTime(); \ |
|
111 _connmon_dur = _connmon_end.MicroSecondsFrom( _connmon_start ); \ |
|
112 {_LIT(s,a); Log::Printf(KCMLogTimeEnd, &s, (TInt)((_connmon_dur.Int64()+500)/1000));} |
|
113 #else |
|
114 _LIT(KCMLogTimeStart, "ConnMon: TIMING: %S start"); |
|
115 _LIT(KCMLogTimeEnd, "ConnMon: TIMING: %S took %d ms"); |
|
116 #define LOGTIMINGSTART(a) \ |
|
117 {/*_LIT(s, a); RDebug::Print(KCMLogTimeStart, &s);*/} \ |
|
118 TTime _connmon_start; \ |
|
119 TTime _connmon_end; \ |
|
120 TTimeIntervalMicroSeconds _connmon_dur; \ |
|
121 _connmon_start.UniversalTime(); |
|
122 |
|
123 #define LOGTIMINGEND(a) \ |
|
124 _connmon_end.UniversalTime(); \ |
|
125 _connmon_dur = _connmon_end.MicroSecondsFrom( _connmon_start ); \ |
|
126 {_LIT(s,a); RDebug::Print(KCMLogTimeEnd, &s, (TInt)((_connmon_dur.Int64()+500)/1000));} |
|
127 #endif |
|
128 #else |
|
129 #define LOGTIMINGSTART(a) |
|
130 #define LOGTIMINGEND(a) |
|
131 #endif |
|
132 |
|
133 #else |
|
134 |
|
135 #define LOG(a) |
|
136 |
|
137 #define LOGIT(a) |
|
138 #define LOGIT1(a,a1) |
|
139 #define LOGIT2(a,a1,a2) |
|
140 #define LOGIT3(a,a1,a2,a3) |
|
141 #define LOGIT4(a,a1,a2,a3,a4) |
|
142 #define LOGIT5(a,a1,a2,a3,a4,a5) |
|
143 #define LOGIT6(a,a1,a2,a3,a4,a5,a6) |
|
144 #define LOGIT11(a,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) |
|
145 |
|
146 #define LOGENTRFN(a) |
|
147 #define LOGEXITFN(a) |
|
148 #define LOGEXITFN1(a,a1) |
|
149 |
|
150 #define LOGTIMINGSTART(a) |
|
151 #define LOGTIMINGEND(a) |
|
152 |
|
153 #endif |
|
154 |
|
155 #ifdef _DEBUG |
|
156 #if ( _CONNMON_LOG_OUTPUT == 2 ) |
|
157 |
|
158 #include <flogger.h> |
|
159 |
|
160 _LIT( KLogFolder,"connmon" ); |
|
161 _LIT( KLogFile,"connmon.txt" ); |
|
162 |
|
163 class Log |
|
164 { |
|
165 public: |
|
166 static inline void Write( const TDesC& aDes); |
|
167 static inline void Printf( TRefByValue<const TDesC> aFmt, ...); |
|
168 static inline void HexDump( |
|
169 const TText* aHeader, |
|
170 const TText* aMargin, |
|
171 const TUint8* aPtr, |
|
172 TInt aLen ); |
|
173 }; |
|
174 |
|
175 inline void Log::Write( const TDesC& aDes ) |
|
176 { |
|
177 RFileLogger::Write( KLogFolder(), KLogFile(), EFileLoggingModeAppend, aDes ); |
|
178 } |
|
179 |
|
180 inline void Log::Printf( TRefByValue<const TDesC> aFmt, ... ) |
|
181 { |
|
182 VA_LIST list; |
|
183 VA_START(list,aFmt); |
|
184 RFileLogger::WriteFormat( KLogFolder(), KLogFile(), EFileLoggingModeAppend, aFmt, list ); |
|
185 } |
|
186 |
|
187 inline void Log::HexDump( |
|
188 const TText* aHeader, |
|
189 const TText* aMargin, |
|
190 const TUint8* aPtr, |
|
191 TInt aLen ) |
|
192 { |
|
193 RFileLogger::HexDump( |
|
194 KLogFolder(), |
|
195 KLogFile(), |
|
196 EFileLoggingModeAppend, |
|
197 aHeader, |
|
198 aMargin, |
|
199 aPtr, |
|
200 aLen ); |
|
201 } |
|
202 |
|
203 #endif // _CONNMON_LOG_OUTPUT |
|
204 #endif // _DEBUG |
|
205 #endif // CONNECTIONMONITORLOG_H |
|
206 |
|
207 // End of file |