|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Defines logger for RawIP NIF. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #ifndef BTTLOG_H__ |
|
23 #define BTTLOG_H__ |
|
24 |
|
25 #include <comms-infras/commsdebugutility.h> |
|
26 |
|
27 #if defined(__FLOG_ACTIVE) || defined(__DEBUGRAWIPSERIALPORT__) |
|
28 // Uncomment any of these macros if you want logging. |
|
29 // -> BTT_LOG_1 : For general logging |
|
30 // -> BTT_LOG_2 : For error and warning logging |
|
31 // -> BTT_LOG_3 : For IP packet information |
|
32 #define __BTT_LOG_1__ 1 |
|
33 //#define __BTT_LOG_2__ 1 |
|
34 //#define __BTT_LOG_3__ 1 |
|
35 #endif |
|
36 |
|
37 #ifdef __BTT_LOG_1__ |
|
38 #define _LOG_L1C1(AAA) iTheLogger->Write(AAA) |
|
39 #define _LOG_L1C2(AAA, BBB) iTheLogger->WriteFormat(AAA, BBB) |
|
40 #define _LOG_L1C3(AAA, BBB, CCC) iTheLogger->WriteFormat(AAA, BBB, CCC) |
|
41 #define _LOG_L1C4(AAA, BBB, CCC, DDD) iTheLogger->WriteFormat(AAA, BBB, CCC, DDD) |
|
42 #define _LOG_L1C5(AAA, BBB, CCC, DDD, EEE) iTheLogger->WriteFormat(AAA, BBB, CCC, DDD, EEE) |
|
43 #else |
|
44 #define _LOG_L1C1(AAA) |
|
45 #define _LOG_L1C2(AAA, BBB) |
|
46 #define _LOG_L1C3(AAA, BBB, CCC) |
|
47 #define _LOG_L1C4(AAA, BBB, CCC, DDD) |
|
48 #define _LOG_L1C5(AAA, BBB, CCC, DDD, EEE) |
|
49 #endif // __BTT_LOG_1__ |
|
50 |
|
51 #ifdef __BTT_LOG_2__ |
|
52 #define _LOG_L2C1(AAA) iTheLogger->Write(AAA) |
|
53 #define _LOG_L2C2(AAA, BBB) iTheLogger->WriteFormat(AAA, BBB) |
|
54 #define _LOG_L2C3(AAA, BBB, CCC) iTheLogger->WriteFormat(AAA, BBB, CCC) |
|
55 #define _LOG_L2C4(AAA, BBB, CCC, DDD) iTheLogger->WriteFormat(AAA, BBB, CCC, DDD) |
|
56 #define _LOG_L2C5(AAA, BBB, CCC, DDD, EEE) iTheLogger->WriteFormat(AAA, BBB, CCC, DDD, EEE) |
|
57 #else |
|
58 #define _LOG_L2C1(AAA) |
|
59 #define _LOG_L2C2(AAA, BBB) |
|
60 #define _LOG_L2C3(AAA, BBB, CCC) |
|
61 #define _LOG_L2C4(AAA, BBB, CCC, DDD) |
|
62 #define _LOG_L2C5(AAA, BBB, CCC, DDD, EEE) |
|
63 #endif // __BTT_LOG_2__ |
|
64 |
|
65 #ifdef __BTT_LOG_3__ |
|
66 #define _LOG_L3C1(AAA) iTheLogger->Write(AAA) |
|
67 #define _LOG_L3C2(AAA, BBB) iTheLogger->WriteFormat(AAA, BBB) |
|
68 #define _LOG_L3C3(AAA, BBB, CCC) iTheLogger->WriteFormat(AAA, BBB, CCC) |
|
69 #define _LOG_L3C4(AAA, BBB, CCC, DDD) iTheLogger->WriteFormat(AAA, BBB, CCC, DDD) |
|
70 #define _LOG_L3C5(AAA, BBB, CCC, DDD, EEE) iTheLogger->WriteFormat(AAA, BBB, CCC, DDD, EEE) |
|
71 #else |
|
72 #define _LOG_L3C1(AAA) |
|
73 #define _LOG_L3C2(AAA, BBB) |
|
74 #define _LOG_L3C3(AAA, BBB, CCC) |
|
75 #define _LOG_L3C4(AAA, BBB, CCC, DDD) |
|
76 #define _LOG_L3C5(AAA, BBB, CCC, DDD, EEE) |
|
77 #endif // __BTT_LOG_3__ |
|
78 |
|
79 #ifdef __BTT_LOG_1__ |
|
80 #define __BTT_LOGGING__ |
|
81 #endif |
|
82 |
|
83 #ifdef __BTT_LOG_2__ |
|
84 #define __BTT_LOGGING__ |
|
85 #endif |
|
86 |
|
87 #ifdef __BTT_LOG_3__ |
|
88 #define __BTT_LOGGING__ |
|
89 #endif |
|
90 |
|
91 #ifdef __BTT_LOGGING__ |
|
92 #define _BTT_LEAVEIFERROR(a) iTheLogger->VerboseLeaveL(__FILE__, __LINE__, a) |
|
93 #define _BTT_PANIC(CAT, CODE) iTheLogger->VerbosePanic(__FILE__, __LINE__, CODE, (TText8*)#CODE, CAT) |
|
94 #else |
|
95 #define _BTT_LEAVEIFERROR(a) User::LeaveIfError(a) |
|
96 #define _BTT_PANIC(CAT, CODE) User::Panic(CAT, CODE) |
|
97 #endif // __BTT_LOGGING__ |
|
98 |
|
99 /** |
|
100 * static class containing methods for logging |
|
101 * text to a logfile. |
|
102 */ |
|
103 class CBttLogger : public CBase |
|
104 { |
|
105 public: |
|
106 static CBttLogger* NewL(const TDesC8& aTag, const TDesC8& aFileName, const TUint32 aInstanceId); |
|
107 ~CBttLogger(); |
|
108 |
|
109 public: |
|
110 void Write(const TDesC8& aText); |
|
111 void WriteFormat(TRefByValue<const TDesC8> aFmt, ...); |
|
112 void VerboseLeaveL(char* aFile, TInt aLine, TInt aReason); |
|
113 void VerbosePanic(char* aFile, |
|
114 TInt aLine, |
|
115 TInt aPanicCode, |
|
116 TText8* aPanicName, |
|
117 const TDesC& aPanicCategory); |
|
118 |
|
119 protected: |
|
120 CBttLogger(); |
|
121 void ConstructL(const TDesC8& aSubDir, const TDesC8& aFileName, const TUint32 aInstanceId); |
|
122 |
|
123 private: |
|
124 class TLogIgnoreOverflow8 : public TDes8Overflow |
|
125 { |
|
126 public: |
|
127 void Overflow(TDes8& /*aDes*/) { } |
|
128 }; |
|
129 |
|
130 private: // owned |
|
131 |
|
132 TUint32 iInstanceId; |
|
133 __FLOG_DECLARATION_MEMBER; |
|
134 }; |
|
135 |
|
136 #endif // BTTLOG_H__ |