|
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: Logger. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef DRMUILOGGER_H |
|
20 #define DRMUILOGGER_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 #include <e32std.h> |
|
26 #include <e32def.h> |
|
27 #include <eikenv.h> |
|
28 #include <flogger.h> |
|
29 |
|
30 |
|
31 #ifdef _DEBUG |
|
32 #define __TEST_DRM_LOG__ |
|
33 #endif // _DEBUG |
|
34 |
|
35 |
|
36 #ifdef __TEST_DRM_LOG__ |
|
37 |
|
38 // CONSTANTS |
|
39 |
|
40 // DRMUI logging directory. |
|
41 _LIT( KDRMUILogDir, "DRMUI" ); |
|
42 // DRMUI log file name. |
|
43 _LIT( KDRMUILogFile, "DMgrWrapper.log" ); |
|
44 // Format string: enter function. |
|
45 _LIT( KDRMUILogEnterFn, "-> %S" ); |
|
46 // Format string: leave function. |
|
47 _LIT( KDRMUILogLeaveFn, "<- %S" ); |
|
48 // Format string: time. |
|
49 _LIT( KDRMUILogTimeFormatString, "%H:%T:%S:%*C2" ); |
|
50 // Format string: timestamp. |
|
51 _LIT( KDRMUILogTimeStampFormatString, "%S %S" ); |
|
52 //Banner message |
|
53 _LIT( KDRMUILogBanner, "DRMUI 3.2"); |
|
54 // Message of exit from app |
|
55 _LIT( KDRMUILogExit, "DRMUI: Application exit"); |
|
56 |
|
57 // DEFINES |
|
58 |
|
59 // Create the log |
|
60 #define CLOG_CREATE { FCreate(); } |
|
61 |
|
62 // Close the log |
|
63 #define CLOG_CLOSE \ |
|
64 { \ |
|
65 RFileLogger::Write \ |
|
66 ( \ |
|
67 KDRMUILogDir, \ |
|
68 KDRMUILogFile, \ |
|
69 EFileLoggingModeAppend, \ |
|
70 KDRMUILogExit \ |
|
71 ); \ |
|
72 } |
|
73 |
|
74 // Write log: enter function. |
|
75 #define CLOG_ENTERFN( a ) \ |
|
76 { \ |
|
77 _LIT( temp, a ); \ |
|
78 RFileLogger::WriteFormat \ |
|
79 ( \ |
|
80 KDRMUILogDir, \ |
|
81 KDRMUILogFile, \ |
|
82 EFileLoggingModeAppend, \ |
|
83 KDRMUILogEnterFn, \ |
|
84 &temp \ |
|
85 ); \ |
|
86 } |
|
87 |
|
88 // Write log: leave function. |
|
89 #define CLOG_LEAVEFN( a ) \ |
|
90 { \ |
|
91 _LIT( temp, a ); \ |
|
92 RFileLogger::WriteFormat \ |
|
93 ( \ |
|
94 KDRMUILogDir, \ |
|
95 KDRMUILogFile, \ |
|
96 EFileLoggingModeAppend, \ |
|
97 KDRMUILogLeaveFn, \ |
|
98 &temp \ |
|
99 ); \ |
|
100 } |
|
101 |
|
102 // Write log: string 'a'. |
|
103 #define CLOG_WRITE( a ) \ |
|
104 { \ |
|
105 _LIT( temp, a ); \ |
|
106 RFileLogger::Write \ |
|
107 ( \ |
|
108 KDRMUILogDir, \ |
|
109 KDRMUILogFile, \ |
|
110 EFileLoggingModeAppend, \ |
|
111 temp \ |
|
112 ); \ |
|
113 } |
|
114 |
|
115 // Write log: formatted. |
|
116 #define CLOG_WRITE_FORMAT( a, b ) \ |
|
117 { \ |
|
118 _LIT( temp, a ); \ |
|
119 RFileLogger::WriteFormat \ |
|
120 ( \ |
|
121 KDRMUILogDir, \ |
|
122 KDRMUILogFile, \ |
|
123 EFileLoggingModeAppend, \ |
|
124 temp, \ |
|
125 b \ |
|
126 ); \ |
|
127 } |
|
128 |
|
129 // Write log: timestamp. |
|
130 #define CLOG_WRITE_TIMESTAMP( a ) \ |
|
131 { \ |
|
132 _LIT( temp, a ); \ |
|
133 TTime time; \ |
|
134 time.HomeTime(); \ |
|
135 TBuf<32> timeBuf; \ |
|
136 TRAPD( err, time.FormatL( timeBuf, KDRMUILogTimeFormatString ) ); \ |
|
137 if ( !err ) \ |
|
138 { \ |
|
139 RFileLogger::WriteFormat \ |
|
140 ( \ |
|
141 KDRMUILogDir, \ |
|
142 KDRMUILogFile, \ |
|
143 EFileLoggingModeAppend, \ |
|
144 KDRMUILogTimeStampFormatString, \ |
|
145 &temp, \ |
|
146 &timeBuf \ |
|
147 ); \ |
|
148 } \ |
|
149 } |
|
150 |
|
151 // Write formatted |
|
152 #define CLOG_WRITEF FPrint |
|
153 |
|
154 |
|
155 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... ) |
|
156 { |
|
157 VA_LIST list; |
|
158 VA_START( list, aFmt ); |
|
159 RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, |
|
160 EFileLoggingModeAppend, aFmt, list ); |
|
161 } |
|
162 |
|
163 |
|
164 inline void FPrint( const TDesC& aDes ) |
|
165 { |
|
166 RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, |
|
167 EFileLoggingModeAppend, aDes ); |
|
168 } |
|
169 |
|
170 |
|
171 inline void FCreate() |
|
172 { |
|
173 TFileName path( _L( "c:\\logs\\" ) ); |
|
174 path.Append( KDRMUILogDir ); |
|
175 path.Append( _L( "\\" ) ); |
|
176 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
177 fs.MkDirAll( path ); |
|
178 RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, |
|
179 EFileLoggingModeOverwrite, KDRMUILogBanner ); |
|
180 } |
|
181 |
|
182 |
|
183 #else // not defined __TEST_DRM_LOG__ |
|
184 |
|
185 inline void FPrint( const TRefByValue<const TDesC> /*aFmt*/, ... ) {}; |
|
186 |
|
187 |
|
188 // DEFINES |
|
189 |
|
190 // Empty definition (disable log). |
|
191 #define CLOG_CREATE |
|
192 |
|
193 // Empty definition (disable log). |
|
194 #define CLOG_CLOSE |
|
195 |
|
196 // Empty definition (disable log). |
|
197 #define CLOG_ENTERFN( a ) |
|
198 |
|
199 // Empty definition (disable log). |
|
200 #define CLOG_LEAVEFN( a ) |
|
201 |
|
202 // Empty definition (disable log). |
|
203 #define CLOG_WRITE( a ) |
|
204 |
|
205 // Empty definition (disable log). |
|
206 #define CLOG_WRITE_FORMAT( a, b ) |
|
207 |
|
208 // Empty definition (disable log). |
|
209 #define CLOG_WRITE_TIMESTAMP( a ) |
|
210 |
|
211 // Empty definition (disable log). |
|
212 #define CCDLGLOGGER_WRITEF 1 ? ((void)0) : FPrint |
|
213 |
|
214 #endif // __TEST_DRM_LOG__ |
|
215 |
|
216 #endif // DRMUILOGGER_H |