|
1 /* |
|
2 * Copyright (c) 2001-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 the License "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 utility. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SECURITYSETTINGSLOGGER_H |
|
20 #define SECURITYSETTINGSLOGGER_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 #include <e32std.h> |
|
26 #include <e32def.h> |
|
27 #include <flogger.h> |
|
28 |
|
29 |
|
30 #ifdef _DEBUG |
|
31 #define __SEC_SETT_LOG__ |
|
32 #endif // _DEBUG |
|
33 |
|
34 |
|
35 #ifdef __SEC_SETT_LOG__ |
|
36 |
|
37 // CONSTANTS |
|
38 |
|
39 // SecuritySettingsLogger logging directory. |
|
40 _LIT( KSecSettLogDir, "TestSecSett" ); |
|
41 // SecSett log file name. |
|
42 _LIT( KSecSettLogFile, "SecSett.log" ); |
|
43 // Format string: enter function. |
|
44 _LIT( KSecSettLogEnterFn, "-> %S" ); |
|
45 // Format string: leave function. |
|
46 _LIT( KSecSettLogLeaveFn, "<- %S" ); |
|
47 // Format string: time. |
|
48 _LIT( KSecSettLogTimeFormatString, "%H:%T:%S:%*C2" ); |
|
49 // Format string: timestamp. |
|
50 _LIT( KSecSettLogTimeStampFormatString, "%S %S" ); |
|
51 |
|
52 // DEFINES |
|
53 |
|
54 // Write log: enter function. |
|
55 #define CLOG_ENTERFN( a ) \ |
|
56 { \ |
|
57 _LIT( temp, a ); \ |
|
58 RFileLogger::WriteFormat \ |
|
59 ( \ |
|
60 KSecSettLogDir, \ |
|
61 KSecSettLogFile, \ |
|
62 EFileLoggingModeAppend, \ |
|
63 KSecSettLogEnterFn, \ |
|
64 &temp \ |
|
65 ); \ |
|
66 } |
|
67 |
|
68 // Write log: leave function. |
|
69 #define CLOG_LEAVEFN( a ) \ |
|
70 { \ |
|
71 _LIT( temp, a ); \ |
|
72 RFileLogger::WriteFormat \ |
|
73 ( \ |
|
74 KSecSettLogDir, \ |
|
75 KSecSettLogFile, \ |
|
76 EFileLoggingModeAppend, \ |
|
77 KSecSettLogLeaveFn, \ |
|
78 &temp \ |
|
79 ); \ |
|
80 } |
|
81 |
|
82 // Write log: string 'a'. |
|
83 #define CLOG_WRITE( a ) \ |
|
84 { \ |
|
85 _LIT( temp, a ); \ |
|
86 RFileLogger::Write \ |
|
87 ( \ |
|
88 KSecSettLogDir, \ |
|
89 KSecSettLogFile, \ |
|
90 EFileLoggingModeAppend, \ |
|
91 temp \ |
|
92 ); \ |
|
93 } |
|
94 |
|
95 // Write log: formatted. |
|
96 #define CLOG_WRITE_FORMAT( a, b ) \ |
|
97 { \ |
|
98 _LIT( temp, a ); \ |
|
99 RFileLogger::WriteFormat \ |
|
100 ( \ |
|
101 KSecSettLogDir, \ |
|
102 KSecSettLogFile, \ |
|
103 EFileLoggingModeAppend, \ |
|
104 temp, \ |
|
105 b \ |
|
106 ); \ |
|
107 } |
|
108 |
|
109 // Write log: timestamp. |
|
110 #define CLOG_WRITE_TIMESTAMP( a ) \ |
|
111 { \ |
|
112 _LIT( temp, a ); \ |
|
113 TTime time; \ |
|
114 time.HomeTime(); \ |
|
115 TBuf<32> timeBuf; \ |
|
116 TRAPD( err, time.FormatL( timeBuf, KSecSettLogTimeFormatString ) ); \ |
|
117 if ( !err ) \ |
|
118 { \ |
|
119 RFileLogger::WriteFormat \ |
|
120 ( \ |
|
121 KSecSettLogDir, \ |
|
122 KSecSettLogFile, \ |
|
123 EFileLoggingModeAppend, \ |
|
124 KSecSettLogTimeStampFormatString, \ |
|
125 &temp, \ |
|
126 &timeBuf \ |
|
127 ); \ |
|
128 } \ |
|
129 } |
|
130 |
|
131 #else // not defined __SEC_SETT_LOG__ |
|
132 |
|
133 // DEFINES |
|
134 |
|
135 // Empty definition (disable log). |
|
136 #define CLOG_ENTERFN( a ) |
|
137 |
|
138 // Empty definition (disable log). |
|
139 #define CLOG_LEAVEFN( a ) |
|
140 |
|
141 // Empty definition (disable log). |
|
142 #define CLOG_WRITE( a ) |
|
143 |
|
144 // Empty definition (disable log). |
|
145 #define CLOG_WRITE_FORMAT( a, b ) |
|
146 |
|
147 // Empty definition (disable log). |
|
148 #define CLOG_WRITE_TIMESTAMP( a ) |
|
149 |
|
150 #endif // __SEC_SETT_LOG__ |
|
151 |
|
152 #endif |