|
1 /* |
|
2 * Copyright (c) 2005-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: Logging macros used by DS plug-in adapters |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __LOGGER_H__ |
|
20 #define __LOGGER_H__ |
|
21 |
|
22 #ifdef _DEBUG |
|
23 #ifdef __WINS__ |
|
24 // File logging for WINS |
|
25 #define __FLOGGING__ |
|
26 #else |
|
27 // Logging with RDebug for target HW |
|
28 #define __CLOGGING__ |
|
29 //#define __FLOGGING__ // enable to log file on target HW |
|
30 #endif //__WINS__ |
|
31 |
|
32 #include <f32file.h> |
|
33 #include <flogger.h> |
|
34 #include <e32std.h> |
|
35 #include <e32def.h> |
|
36 |
|
37 _LIT(KLogDir,"MMS"); |
|
38 _LIT(KLogFile,"MMSDataproviderLog.txt"); |
|
39 _LIT( KLogFormat, "[MMSDS] %S"); |
|
40 |
|
41 _LIT(KLogEnterFn, "%S : Begin"); |
|
42 _LIT(KLogLeaveFn, "%S : End"); |
|
43 |
|
44 /** |
|
45 * Old logging macros, for public use |
|
46 */ |
|
47 #ifdef __FLOGGING__ |
|
48 #define LOG( AAA ) RFileLogger::Write( KLogDir,KLogFile,EFileLoggingModeAppend,AAA ) |
|
49 #else |
|
50 #define LOG( AAA ) |
|
51 #endif |
|
52 #define LOG2( text, par1 ) { FPrint( text, par1 ); } |
|
53 |
|
54 |
|
55 /** |
|
56 * new logging macros, for public use |
|
57 */ |
|
58 #define LOGGER_ENTERFN( name ) {_LIT( temp, name ); FPrint( KLogEnterFn, &temp );} |
|
59 #define LOGGER_LEAVEFN( name ) {_LIT( temp, name ); FPrint( KLogLeaveFn, &temp );} |
|
60 |
|
61 #define LOGGER_WRITE( text ) {_LIT( KTemp, text ); FPrint( KTemp );} |
|
62 #define LOGGER_WRITE_1( text,par1 ) {_LIT( KTemp, text ); FPrint( KTemp, par1 );} |
|
63 #define LOGGER_MSG_EC( text,par1 ) {_LIT( KTemp, text ); FPrint( KTemp, par1 );} |
|
64 |
|
65 |
|
66 // Declare the FPrint function |
|
67 inline void FPrint( TRefByValue<const TDesC> aFmt, ...) |
|
68 { |
|
69 VA_LIST list; |
|
70 VA_START(list,aFmt); |
|
71 #if defined ( __FLOGGING__ ) |
|
72 RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list ); |
|
73 #endif |
|
74 #if defined ( __CLOGGING__ ) |
|
75 const TInt KMaxLogData = 0x200; |
|
76 TBuf< KMaxLogData > buf; |
|
77 buf.FormatList( aFmt, list ); |
|
78 |
|
79 RDebug::Print( KLogFormat, &buf ); |
|
80 #endif |
|
81 } |
|
82 #else // no _DEBUG defined |
|
83 |
|
84 #define LOG( AAA ) |
|
85 |
|
86 #define LOGGER_ENTERFN( name ) |
|
87 #define LOGGER_LEAVEFN( name ) |
|
88 #define LOGGER_WRITE( text ) |
|
89 #define LOGGER_WRITE_1( text,par1 ) |
|
90 #define LOGGER_MSG_EC( text,par1 ) |
|
91 |
|
92 #endif // _DEBUG |
|
93 |
|
94 #endif // __LOGGER_H__ |
|
95 |