|
1 /* |
|
2 * Copyright (c) 2002 - 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 "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: Provides macros for logging |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __NWLOGGER_H__ |
|
21 #define __NWLOGGER_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32def.h> |
|
25 |
|
26 /* |
|
27 ----------------------------------------------------------------------------- |
|
28 |
|
29 USER LOG SELECTION |
|
30 |
|
31 ----------------------------------------------------------------------------- |
|
32 */ |
|
33 |
|
34 inline TUint KNWLOGMASK() |
|
35 { |
|
36 return 0x8fffffff; // This is default mask value. |
|
37 } // User can change mask value to get different king of logging. |
|
38 |
|
39 #ifndef _DEBUG |
|
40 |
|
41 /*************************** |
|
42 * Logging method variants: |
|
43 * 0 = No logging |
|
44 * 1 = Flogger |
|
45 * 2 = RDebug |
|
46 ***************************/ |
|
47 |
|
48 #define NW_LOGGING_METHOD 0 // UREL BUILD |
|
49 |
|
50 #else |
|
51 |
|
52 #ifdef __WINS__ |
|
53 #define NW_LOGGING_METHOD 1 // UDEB BUILD, WINS |
|
54 #else |
|
55 #define NW_LOGGING_METHOD 2 // UDEB BUILD, HW |
|
56 #endif // __WINS__ |
|
57 |
|
58 #endif // _DEBUG |
|
59 |
|
60 |
|
61 // Next is for backward compatibility |
|
62 #if NW_LOGGING_METHOD > 0 |
|
63 #define NW_LOGGING_ENABLED |
|
64 #endif |
|
65 |
|
66 |
|
67 /* |
|
68 ----------------------------------------------------------------------------- |
|
69 |
|
70 LOGGING OPTIONS |
|
71 |
|
72 ----------------------------------------------------------------------------- |
|
73 */ |
|
74 |
|
75 #define KNWOBJECT 0x00000001 // Construction and destruction |
|
76 |
|
77 #define KNWERROR 0x00000002 // Error that can be handled. Describe reason for error situation. |
|
78 #define KNWPANIC 0x00000004 // Critical error: Panic. |
|
79 |
|
80 #define KNWMESIN 0x00000008 // From client to NW message |
|
81 #define KNWMESOUT 0x00000010 // From NW to client message |
|
82 #define KNWMESINT 0x00000020 // TELE internal message |
|
83 |
|
84 #define KNWREQIN 0x00000040 // Public interface methods |
|
85 #define KNWREQOUT 0x00000080 // Set outgoing request |
|
86 #define KNWREQEND 0x00000100 // Complete request |
|
87 |
|
88 #define KNWINT 0x00000200 // Internal activity |
|
89 |
|
90 #define KNWMSTATE 0x00000400 // Component state changes |
|
91 |
|
92 #define KNWGENERAL 0x00000800 // For deprecated NWLOGxxx-macros and for temporary usage |
|
93 |
|
94 |
|
95 /* |
|
96 ----------------------------------------------------------------------------- |
|
97 |
|
98 LOG SETTINGS |
|
99 |
|
100 ----------------------------------------------------------------------------- |
|
101 */ |
|
102 |
|
103 #if NW_LOGGING_METHOD == 1 // Flogger |
|
104 |
|
105 #include <flogger.h> |
|
106 _LIT(KNwLogFolder,"NW"); |
|
107 _LIT(KTfLogFile,"NWLOG.TXT"); |
|
108 |
|
109 #elif NW_LOGGING_METHOD == 2 // RDebug |
|
110 |
|
111 #include <e32svr.h> |
|
112 |
|
113 #endif |
|
114 |
|
115 |
|
116 /* |
|
117 ----------------------------------------------------------------------------- |
|
118 |
|
119 LOGGING MACROs |
|
120 |
|
121 USE THESE MACROS IN YOUR CODE ! |
|
122 |
|
123 ----------------------------------------------------------------------------- |
|
124 */ |
|
125 |
|
126 #if NW_LOGGING_METHOD == 1 // Flogger |
|
127 |
|
128 #define NWLOGTEXT(Type,AAA) { if((KNWLOGMASK()&(Type))==(Type)) { RFileLogger::Write(KNwLogFolder(),KTfLogFile(),EFileLoggingModeAppend, AAA); }} |
|
129 #define NWLOGSTRING(Type,AAA) { if((KNWLOGMASK()&(Type))==(Type)) { _LIT(tempLogDes,AAA); RFileLogger::Write(KNwLogFolder(),KTfLogFile(),EFileLoggingModeAppend,tempLogDes()); }} |
|
130 #define NWLOGSTRING2(Type,AAA,BBB) { if((KNWLOGMASK()&(Type))==(Type)) { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KNwLogFolder(),KTfLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB); }} |
|
131 #define NWLOGSTRING3(Type,AAA,BBB,CCC) { if((KNWLOGMASK()&(Type))==(Type)) { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KNwLogFolder(),KTfLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC); }} |
|
132 #define NWLOGSTRING4(Type,AAA,BBB,CCC,DDD) { if((KNWLOGMASK()&(Type))==(Type)) { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KNwLogFolder(),KTfLogFile(),EFileLoggingModeAppend,TRefByValue<const TDesC>(tempLogDes()),BBB,CCC,DDD); }} |
|
133 |
|
134 #elif NW_LOGGING_METHOD == 2 // RDebug |
|
135 |
|
136 #define NWLOGTEXT(Type,AAA) { if((KNWLOGMASK()&(Type))==(Type)) RDebug::Print(AAA); } |
|
137 #define NWLOGSTRING(Type,AAA) { if((KNWLOGMASK()&(Type))==(Type)) RDebug::Print(_L(AAA)); } |
|
138 #define NWLOGSTRING2(Type,AAA,BBB) { if((KNWLOGMASK()&(Type))==(Type)) RDebug::Print(_L(AAA),BBB); } |
|
139 #define NWLOGSTRING3(Type,AAA,BBB,CCC) { if((KNWLOGMASK()&(Type))==(Type)) RDebug::Print(_L(AAA),BBB,CCC); } |
|
140 #define NWLOGSTRING4(Type,AAA,BBB,CCC,DDD) { if((KNWLOGMASK()&(Type))==(Type)) RDebug::Print(_L(AAA),BBB,CCC,DDD); } |
|
141 |
|
142 #else // NW_LOGGING_METHOD == 0 or invalid |
|
143 |
|
144 #define NWLOGTEXT(Type,AAA) // Example: NWLOGTEXT(KNWMESOUT, own_desc); |
|
145 #define NWLOGSTRING(Type,AAA) // Example: NWLOGSTRING(KNWMESIN, "Test"); |
|
146 #define NWLOGSTRING2(Type,AAA,BBB) // Example: NWLOGSTRING(KNWMESINT, "Test %i", aValue); |
|
147 #define NWLOGSTRING3(Type,AAA,BBB,CCC) // Example: NWLOGSTRING(KNWMESOUT, "Test %i %i", aValue1, aValue2); |
|
148 #define NWLOGSTRING4(Type,AAA,BBB,CCC,DDD) // Example: NWLOGSTRING(KNWMESOUT, "Test %i %i %i", aValue1, aValue2, aValue3); |
|
149 |
|
150 #endif // NW_LOGGING_METHOD |
|
151 |
|
152 |
|
153 |
|
154 #endif // NWLOGGER_H |