|
1 /* |
|
2 * Copyright (c) 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 code fot the dmadpki |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef VPNLOGGER_H |
|
23 #define VPNLOGGER_H |
|
24 |
|
25 #if defined(_DEBUG) |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <flogger.h> |
|
29 |
|
30 |
|
31 NONSHARABLE_CLASS(TTraceItem) |
|
32 { |
|
33 public: |
|
34 inline TTraceItem(const TDesC& aTraceName); |
|
35 inline ~TTraceItem(); |
|
36 |
|
37 inline static void TraceCleanupOperation(TAny* aItem); |
|
38 private: |
|
39 |
|
40 HBufC* iTraceName; |
|
41 TBool iMethodHasLeft; |
|
42 }; |
|
43 |
|
44 |
|
45 NONSHARABLE_CLASS(CVpnDebugLogger) : public CBase |
|
46 { |
|
47 public: |
|
48 |
|
49 inline static void InitializeDebugLoggerL(const TDesC& aFolder, const TDesC& aFileName); |
|
50 inline static void FinalizeDebugLogger(); |
|
51 inline static void LogWrite(const TDesC& aText); |
|
52 inline static void LogWrite(const TDesC8& aText); |
|
53 |
|
54 inline static void LogWriteF(TRefByValue<const TDesC> aFmt, ...); |
|
55 inline static void LogWriteF(TRefByValue<const TDesC8> aFmt, ...); |
|
56 |
|
57 |
|
58 inline static void HexWrite(const TDesC8& aData); |
|
59 |
|
60 |
|
61 private: |
|
62 inline void ConstructL(const TDesC& aFolder, const TDesC& aFileName); |
|
63 inline ~CVpnDebugLogger(); |
|
64 |
|
65 inline static void TimeStamp(TDes& aBuffer); |
|
66 inline static CVpnDebugLogger* VpnDebugLogger(); |
|
67 |
|
68 inline void WriteLogRaw(const TDesC& aLogMessage); |
|
69 |
|
70 |
|
71 RFileLogger iFileLogger; |
|
72 TUint iCallDepth; |
|
73 |
|
74 TBuf<512> iDebugString; |
|
75 friend class TTraceItem; |
|
76 |
|
77 TUint8 iReferenceCount; |
|
78 }; |
|
79 |
|
80 #define INITIALIZE_DEBUG_LOG_L(a, b) CVpnDebugLogger::InitializeDebugLoggerL((a), (b)) |
|
81 #define FINALIZE_DEBUG_LOG CVpnDebugLogger::FinalizeDebugLogger(); |
|
82 |
|
83 /** |
|
84 * Trace can't be used inside LC methods. |
|
85 */ |
|
86 #define TRACE(a) TTraceItem __trace(TPtrC((const TText *)L ## a)) |
|
87 #define DEBUG_LOG(a) CVpnDebugLogger::LogWrite(a) |
|
88 #define DEBUG_LOG1(a, b) CVpnDebugLogger::LogWriteF((a), (b)) |
|
89 #define DEBUG_LOG2(a, b, c) CVpnDebugLogger::LogWriteF((a), (b), (c)) |
|
90 |
|
91 #define DEBUG_LOG_HEX(a) CVpnDebugLogger::HexWrite((a)) |
|
92 |
|
93 #include "vpnlogger.inl" |
|
94 |
|
95 #else |
|
96 |
|
97 #define INITIALIZE_DEBUG_LOG_L(a, b) |
|
98 #define FINALIZE_DEBUG_LOG |
|
99 #define TRACE(a) |
|
100 #define DEBUG_LOG(a) |
|
101 #define DEBUG_LOG1(a, b) |
|
102 #define DEBUG_LOG2(a, b, c) |
|
103 |
|
104 #define DEBUG_LOG_HEX(a) |
|
105 |
|
106 |
|
107 #endif //!defined(_DEBUG) |
|
108 #endif //VPNLOGGER_H |