|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Logging macros for MsgErrorWatcher.dll |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // ========== LOGGING MACROS =============================== |
|
22 |
|
23 #ifndef MSGERRORWATCHERLOGGING_H |
|
24 #define MSGERRORWATCHERLOGGING_H |
|
25 |
|
26 #ifdef _DEBUG |
|
27 |
|
28 #ifndef USE_LOGGER |
|
29 #define USE_LOGGER |
|
30 #endif |
|
31 |
|
32 |
|
33 #include <e32std.h> |
|
34 #include <e32def.h> |
|
35 #include <flogger.h> |
|
36 |
|
37 |
|
38 #ifdef USE_RDEBUG |
|
39 |
|
40 _LIT(KMEWLogBanner, "MEW - MsgErrorWatcer"); |
|
41 _LIT(KMEWLogEnterFn, "MEW: >> %S"); |
|
42 _LIT(KMEWLogLeaveFn, "MEW: << %S"); |
|
43 _LIT(KMEWLogWrite, "MEW: %S"); |
|
44 _LIT(KMEWLogTag, "MEW: "); |
|
45 _LIT(KMEWLogExit, "MEW: Application exit"); |
|
46 _LIT(KMEWLogTimeFormatString, "%H:%T:%S:%*C2"); |
|
47 |
|
48 #define MEWLOGGER_CREATE(a) {RDebug::Print(KMEWLogBanner);} |
|
49 #define MEWLOGGER_DELETE {RDebug::Print(KMEWLogExit);} |
|
50 #define MEWLOGGER_ENTERFN(a) {_LIT(temp, a); RDebug::Print(KMEWLogEnterFn, &temp);} |
|
51 #define MEWLOGGER_LEAVEFN(a) {_LIT(temp, a); RDebug::Print(KMEWLogLeaveFn, &temp);} |
|
52 #define MEWLOGGER_WRITE(a) {_LIT(temp, a); RDebug::Print(KMEWLogWrite, &temp);} |
|
53 #define MEWLOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KMEWLogTimeFormatString ); buffer.Insert(0, temp); buffer.Insert(0, KMEWLogTag); RDebug::Print(buffer); } |
|
54 #define MEWLOGGER_WRITEF RDebug::Print |
|
55 |
|
56 #else |
|
57 |
|
58 _LIT( KMEWLogDir, "MEW"); |
|
59 _LIT( KMEWLogFile, "MEW.txt"); |
|
60 _LIT8(KMEWLogBanner, "MEW - MsgErrorWatcer"); |
|
61 _LIT8(KMEWLogEnterFn, "MEW: >> %S"); |
|
62 _LIT8(KMEWLogLeaveFn, "MEW: << %S"); |
|
63 _LIT8(KMEWLogExit, "MEW: Application exit"); |
|
64 _LIT( KMEWLogTimeFormatString, "%H:%T:%S:%*C2"); |
|
65 |
|
66 #define MEWLOGGER_CREATE(a) {FCreate(a);} |
|
67 #define MEWLOGGER_DELETE {RFileLogger::Write(KMEWLogDir, KMEWLogFile, EFileLoggingModeAppend, KMEWLogExit);} |
|
68 #define MEWLOGGER_ENTERFN(a) {_LIT8(temp, a); RFileLogger::WriteFormat(KMEWLogDir, KMEWLogFile, EFileLoggingModeAppend, KMEWLogEnterFn, &temp);} |
|
69 #define MEWLOGGER_LEAVEFN(a) {_LIT8(temp, a); RFileLogger::WriteFormat(KMEWLogDir, KMEWLogFile, EFileLoggingModeAppend, KMEWLogLeaveFn, &temp);} |
|
70 #define MEWLOGGER_WRITE(a) {_LIT(temp, a); RFileLogger::Write(KMEWLogDir, KMEWLogFile, EFileLoggingModeAppend, temp);} |
|
71 #define MEWLOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KMEWLogTimeFormatString ); buffer.Insert(0, temp); RFileLogger::Write(KMEWLogDir, KMEWLogFile, EFileLoggingModeAppend, buffer); } |
|
72 #define MEWLOGGER_WRITEF FPrint |
|
73 |
|
74 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...) |
|
75 { |
|
76 VA_LIST list; |
|
77 VA_START(list,aFmt); |
|
78 RFileLogger::WriteFormat(KMEWLogDir, KMEWLogFile, EFileLoggingModeAppend, aFmt, list); |
|
79 } |
|
80 |
|
81 inline void FPrint(const TDesC& aDes) |
|
82 { |
|
83 RFileLogger::WriteFormat(KMEWLogDir, KMEWLogFile, EFileLoggingModeAppend, aDes); |
|
84 } |
|
85 |
|
86 inline void FHex(const TUint8* aPtr, TInt aLen) |
|
87 { |
|
88 RFileLogger::HexDump(KMEWLogDir, KMEWLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen); |
|
89 } |
|
90 |
|
91 inline void FHex(const TDesC8& aDes) |
|
92 { |
|
93 FHex(aDes.Ptr(), aDes.Length()); |
|
94 } |
|
95 |
|
96 inline void FCreate(RFs& aFs) |
|
97 { |
|
98 TFileName path(_L("c:\\logs\\")); |
|
99 path.Append(KMEWLogDir); |
|
100 path.Append(_L("\\")); |
|
101 aFs.MkDirAll(path); |
|
102 RFileLogger::WriteFormat(KMEWLogDir, KMEWLogFile, EFileLoggingModeOverwrite, KMEWLogBanner); |
|
103 } |
|
104 |
|
105 #endif // USE_RDEBUG |
|
106 |
|
107 #else // not _DEBUG |
|
108 |
|
109 // dummy inline FPrint for MEWLOGGER_WRITEF macro. |
|
110 inline TInt FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { return 0; } |
|
111 |
|
112 #define MEWLOGGER_CREATE(a) |
|
113 #define MEWLOGGER_DELETE |
|
114 #define MEWLOGGER_ENTERFN(a) |
|
115 #define MEWLOGGER_LEAVEFN(a) |
|
116 #define MEWLOGGER_WRITE(a) |
|
117 // if USE_LOGGER not defined this call to FPrint gets optimized away. |
|
118 #define MEWLOGGER_WRITEF 1 ? 0 : FPrint |
|
119 #define MEWLOGGER_WRITE_TIMESTAMP(a) |
|
120 |
|
121 #endif // _DEBUG |
|
122 |
|
123 #endif // MSGERRORWATCHERLOGGING_H |
|
124 |
|
125 // ========================================================= |