|
1 /* |
|
2 * Copyright (c) 2002 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: Implemented logger functionality of the module |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef TELSERVICE_LOGGER_H |
|
20 #define TELSERVICE_LOGGER_H |
|
21 |
|
22 #if defined _DEBUG |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <flogger.h> |
|
27 |
|
28 // log files are stored to KDebugLogDirFull folder |
|
29 _LIT(KDebugLogDependency,"C:\\Logs\\"); |
|
30 _LIT(KDebugLogDoubleBackSlash,"\\"); |
|
31 |
|
32 _LIT(KDebugLogDir, "TelService"); |
|
33 _LIT(KDebugLogFile, "TelService.log"); |
|
34 _LIT(KDebugLogTitle, "- BrowserTelServiceNotifier Debug Log File -"); |
|
35 _LIT( KTelServiceLogMessageAppBanner, "TelService: module (%d.%d.%d) started" ); |
|
36 _LIT( KDebugLogEnterFn, "TelService: -> %S" ); |
|
37 _LIT( KDebugLogLeaveFn, "TelService: <- %S" ); |
|
38 _LIT( KDebugLogTimeFormatString, "%H:%T:%S:%*C3" ); |
|
39 _LIT( KDebugLogExit, "TelService: module exit" ); |
|
40 |
|
41 |
|
42 // MACROS |
|
43 |
|
44 /** |
|
45 * Use this macro in order to initialize logger : |
|
46 * - create log directory, |
|
47 * - write version information into the log file |
|
48 */ |
|
49 #define TELSERVICE_CREATE { TFileName path( KDebugLogDependency ); path.Append( KDebugLogDir ); path.Append( KDebugLogDoubleBackSlash ); RFs& fs = CEikonEnv::Static()->FsSession(); fs.MkDirAll( path ); RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile, EFileLoggingModeOverwrite, KTelServiceLogMessageAppBanner ); } |
|
50 #define TELSERVICE_CREATE_X( x ) { _LIT( logfile, x ); TFileName path( KDebugLogDependency ); path.Append( KDebugLogDir ); path.Append( KDebugLogDoubleBackSlash ); RFs fs; fs.Connect(); fs.MkDirAll( path ); RFileLogger::WriteFormat( KDebugLogDir, logfile , EFileLoggingModeOverwrite, KTelServiceLogMessageAppBanner ); fs.Close();} |
|
51 |
|
52 /** |
|
53 * Use this macro for writing information about exiting. |
|
54 */ |
|
55 #define TELSERVICE_DELETE { RFileLogger::Write( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, KDebugLogExit ); } |
|
56 #define TELSERVICE_DELETE_X( x ) { _LIT( logfile, x ); RFileLogger::Write( KDebugLogDir, logfile, EFileLoggingModeAppend, KDebugLogExit ); } |
|
57 |
|
58 /** |
|
59 * Use this function at the entry point of any functions. |
|
60 * @param a Entry information of the method. |
|
61 */ |
|
62 #define TELSERVICE_ENTERFN( a ) { _LIT( temp, a ); RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, KDebugLogEnterFn, &temp ); } |
|
63 #define TELSERVICE_ENTERFN_X( a, x ) { _LIT( temp, a ); _LIT( logfile, x ); RFileLogger::WriteFormat( KDebugLogDir, logfile, EFileLoggingModeAppend, KDebugLogEnterFn, &temp ); } |
|
64 |
|
65 /** |
|
66 * Use this function right before you leave the method. |
|
67 * @param a Leaving information of the method. |
|
68 */ |
|
69 #define TELSERVICE_LEAVEFN( a ) { _LIT( temp, a ); RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, KDebugLogLeaveFn, &temp ); } |
|
70 #define TELSERVICE_LEAVEFN_X( a, x ) { _LIT( temp, a ); _LIT( logfile, x ); RFileLogger::WriteFormat( KDebugLogDir, logfile, EFileLoggingModeAppend, KDebugLogLeaveFn, &temp ); } |
|
71 |
|
72 /** |
|
73 * Use this function at any points of a function for logging the current state. |
|
74 * @param a String to be written into logfile about the current state |
|
75 */ |
|
76 #define TELSERVICE_WRITE( a ) { _LIT( temp, a ); RFileLogger::Write( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, temp ); } |
|
77 #define TELSERVICE_WRITE_X( a, x ) { _LIT( temp, a ); _LIT( logfile, x ); RFileLogger::Write( KDebugLogDir, logfile, EFileLoggingModeAppend, temp ); } |
|
78 |
|
79 /** |
|
80 * Use this function at any points of a function for logging the current state. |
|
81 * You can use printf-like formats, but with only one parameter to be substituted.. |
|
82 * @param a Format string, |
|
83 * @param b Parameter to be substituted. |
|
84 */ |
|
85 #define TELSERVICE_WRITE_FORMAT( a, b ) { _LIT( temp, a ); RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, temp, b ); } |
|
86 #define TELSERVICE_WRITE_FORMAT_X( a, b, x ) { _LIT( temp, a ); _LIT( logfile, x ); RFileLogger::WriteFormat( KDebugLogDir, logfile, EFileLoggingModeAppend, temp, b ); } |
|
87 |
|
88 /** |
|
89 * Use this function at any points of a function for logging the current state. |
|
90 * The current date/time stamp is written besides the string you give. |
|
91 * @param a String to be written into logfile about the current state |
|
92 */ |
|
93 #define TELSERVICE_WRITE_TIMESTAMP( a ) { _LIT( temp, a ); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KDebugLogTimeFormatString ); buffer.Insert( 0, temp ); RFileLogger::Write( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, buffer); } |
|
94 #define TELSERVICE_WRITE_TIMESTAMP_X( a, x ) { _LIT( temp, a ); _LIT( logfile, x ); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KDebugLogTimeFormatString ); buffer.Insert( 0, temp ); RFileLogger::Write( KDebugLogDir, logfile, EFileLoggingModeAppend, buffer); } |
|
95 |
|
96 #else // _DEBUG |
|
97 |
|
98 // Empty macros |
|
99 #define TELSERVICE_CREATE |
|
100 #define TELSERVICE_CREATE_X( x ) |
|
101 #define TELSERVICE_DELETE |
|
102 #define TELSERVICE_DELETE_X( x ) |
|
103 #define TELSERVICE_ENTERFN( a ) |
|
104 #define TELSERVICE_ENTERFN_X( a, x ) |
|
105 #define TELSERVICE_LEAVEFN( a ) |
|
106 #define TELSERVICE_LEAVEFN_X( a, x ) |
|
107 #define TELSERVICE_WRITE( a ) |
|
108 #define TELSERVICE_WRITE_X( a, x ) |
|
109 #define TELSERVICE_WRITE_FORMAT( a, b ) |
|
110 #define TELSERVICE_WRITE_FORMAT_X( a, b, x ) |
|
111 #define TELSERVICE_WRITE_TIMESTAMP( a ) |
|
112 #define TELSERVICE_WRITE_TIMESTAMP_X( a, x ) |
|
113 |
|
114 #endif // _DEBUG |
|
115 |
|
116 #endif // TELSERVICE_LOGGER_H |
|
117 |
|
118 // End of file |