|
1 /* |
|
2 * Copyright (c) 2002-2010 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: This file defines trace and log macros for SWI Daemon. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SWINSTDEBUG_H |
|
20 #define SWINSTDEBUG_H |
|
21 |
|
22 //----------------------------------------------------------------------------- |
|
23 #ifdef _DEBUG // Trace if debug |
|
24 //----------------------------------------------------------------------------- |
|
25 |
|
26 // This will enable trace printing to Musti. |
|
27 // Comment off if log file is needed. |
|
28 #define _PRINT_TO_TRACE |
|
29 |
|
30 // This will enable printing to log file c:\logs\SWIDaemon\SWIDaemon.txt |
|
31 // Comment off is trace is needed. |
|
32 //#define _PRINT_TO_LOG |
|
33 |
|
34 //----------------------------- |
|
35 #ifdef _PRINT_TO_TRACE |
|
36 //----------------------------- |
|
37 #include <e32debug.h> |
|
38 |
|
39 const TInt KMaxDebugSize = 256; |
|
40 const TInt KMaxPrefix = 20; |
|
41 _LIT( KTracePrefixDaemon, "[SWIDaemon]: " ); |
|
42 |
|
43 inline void PrintDebugData( TRefByValue<const TDesC> aFmt, ... ) |
|
44 { |
|
45 VA_LIST list; |
|
46 VA_START( list, aFmt ); |
|
47 TBuf<KMaxDebugSize> buf; |
|
48 buf.Copy( KTracePrefixDaemon ); |
|
49 buf.AppendFormatList( aFmt, list ); |
|
50 RDebug::Print( buf ); |
|
51 } |
|
52 |
|
53 #define FLOG(a) { PrintDebugData(a); } |
|
54 #define FLOG_1(a,b) { PrintDebugData(a,b); } |
|
55 #define FLOG_2(a,b,c) { PrintDebugData(a,b,c); } |
|
56 #define FLOG_3(a,b,c,d) { PrintDebugData(a,b,c,d); } |
|
57 |
|
58 //#define FLOG(a) { RDebug::Print(a); } |
|
59 //#define FLOG_1(a,b) { RDebug::Print(a,b); } |
|
60 //#define FLOG_2(a,b,c) { RDebug::Print(a,b,c); } |
|
61 //#define FLOG_3(a,b,c,d) { RDebug::Print(a,b,c,d); } |
|
62 |
|
63 //----------------------------- |
|
64 # endif // _PRINT_TO_TRACE |
|
65 //----------------------------- |
|
66 |
|
67 //----------------------------- |
|
68 #ifdef _PRINT_TO_LOG |
|
69 //----------------------------- |
|
70 #include <e32std.h> |
|
71 |
|
72 #define FLOG(a) { FPrint(a); } |
|
73 #define FLOG_1(a,b) { FPrint(a,b); } |
|
74 #define FLOG_2(a,b,c) { FPrint(a,b,c); } |
|
75 #define FLOG_3(a,b,c,d) { FPrint(a,b,c,d); } |
|
76 |
|
77 #include <flogger.h> |
|
78 // Log file in c:\logs\SWIDaemon\ |
|
79 _LIT(KLogFile,"SWIDeamon.txt"); |
|
80 // Log dir |
|
81 _LIT(KLogDir,"SWIDaemon"); |
|
82 |
|
83 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... ) |
|
84 { |
|
85 VA_LIST list; |
|
86 VA_START( list, aFmt ); |
|
87 RFileLogger::WriteFormat( KLogDir, |
|
88 KLogFile, |
|
89 EFileLoggingModeAppend, |
|
90 aFmt, |
|
91 list ); |
|
92 } |
|
93 //----------------------------- |
|
94 # endif // _PRINT_TO_LOG |
|
95 //----------------------------- |
|
96 |
|
97 //----------------------------------------------------------------------------- |
|
98 #else // No trace or logs |
|
99 //----------------------------------------------------------------------------- |
|
100 |
|
101 #define FLOG(a) |
|
102 #define FLOG_1(a,b) |
|
103 #define FLOG_2(a,b,c) |
|
104 #define FLOG_3(a,b,c,d) |
|
105 |
|
106 #endif // _DEBUG |
|
107 |
|
108 #endif // SWINSTDEBUG_H |
|
109 |
|
110 // EOF |