|
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: MsgEditorLogging declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef MSGEDITORLOGGING_H |
|
21 #define MSGEDITORLOGGING_H |
|
22 |
|
23 // ========== LOGGING MACROS =============================== |
|
24 |
|
25 #if defined( _DEBUG ) || defined( USE_LOGGER ) |
|
26 |
|
27 #include <e32std.h> |
|
28 #include <e32def.h> |
|
29 #include <eikenv.h> |
|
30 #include <flogger.h> |
|
31 |
|
32 #ifdef USE_RDEBUG |
|
33 |
|
34 _LIT( KMEBLogBanner, "MEB" ); |
|
35 _LIT( KMEBLogEnterFn, "MEB: enter --> %S" ); |
|
36 _LIT( KMEBLogLeaveFn, "MEB: leave <-- %S" ); |
|
37 _LIT( KMEBLogWrite, "MEB: %S" ); |
|
38 _LIT( KMEBLogTag, "MEB: " ); |
|
39 _LIT( KMEBLogExit, "MEB: Application exit" ); |
|
40 _LIT( KMEBLogTimeFormatString, "%H:%T:%S:%*C2" ); |
|
41 |
|
42 |
|
43 #define MEBLOGGER_CREATE {RDebug::Print(KMEBLogBanner);} |
|
44 #define MEBLOGGER_DELETE {RDebug::Print(KMEBLogExit);} |
|
45 #define MEBLOGGER_ENTERFN(a) {_LIT(temp, a); RDebug::Print(KMEBLogEnterFn, &temp);} |
|
46 #define MEBLOGGER_LEAVEFN(a) {_LIT(temp, a); RDebug::Print(KMEBLogLeaveFn, &temp);} |
|
47 #define MEBLOGGER_WRITE(a) {_LIT(temp, a); RDebug::Print(KMEBLogWrite, &temp);} |
|
48 #define MEBLOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KMEBLogTimeFormatString ); buffer.Insert(0, temp); buffer.Insert(0, KMEBLogTag); RDebug::Print(buffer); } |
|
49 #define MEBLOGGER_WRITEF RDebug::Print |
|
50 |
|
51 #else // USE_RDEBUG |
|
52 |
|
53 _LIT( KMEBLogDir, "MEB" ); |
|
54 _LIT( KMEBLogFile, "MEB.txt" ); |
|
55 _LIT8( KMEBLogBanner, "MEB" ); |
|
56 _LIT8( KMEBLogEnterFn, "MEB: -> %S" ); |
|
57 _LIT8( KMEBLogLeaveFn, "MEB: <- %S" ); |
|
58 _LIT8( KMEBLogExit, "MEB: Application exit" ); |
|
59 _LIT( KMEBLogTimeFormatString, "%H:%T:%S:%*C2" ); |
|
60 |
|
61 #define MEBLOGGER_CREATE {FCreate();} |
|
62 #define MEBLOGGER_DELETE {RFileLogger::Write(KMEBLogDir, KMEBLogFile, EFileLoggingModeAppend, KMEBLogExit);} |
|
63 #define MEBLOGGER_ENTERFN(a) {_LIT8(temp, a); RFileLogger::WriteFormat(KMEBLogDir, KMEBLogFile, EFileLoggingModeAppend, KMEBLogEnterFn, &temp);} |
|
64 #define MEBLOGGER_LEAVEFN(a) {_LIT8(temp, a); RFileLogger::WriteFormat(KMEBLogDir, KMEBLogFile, EFileLoggingModeAppend, KMEBLogLeaveFn, &temp);} |
|
65 #define MEBLOGGER_WRITE(a) {_LIT(temp, a); RFileLogger::Write(KMEBLogDir, KMEBLogFile, EFileLoggingModeAppend, temp);} |
|
66 #define MEBLOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KMEBLogTimeFormatString ); buffer.Insert(0, temp); RFileLogger::Write(KMEBLogDir, KMEBLogFile, EFileLoggingModeAppend, buffer); } |
|
67 #define MEBLOGGER_WRITEF FPrint |
|
68 |
|
69 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...) |
|
70 { |
|
71 VA_LIST list; |
|
72 VA_START(list,aFmt); |
|
73 RFileLogger::WriteFormat(KMEBLogDir, KMEBLogFile, EFileLoggingModeAppend, aFmt, list); |
|
74 } |
|
75 |
|
76 inline void FPrint(const TDesC& aDes) |
|
77 { |
|
78 RFileLogger::WriteFormat(KMEBLogDir, KMEBLogFile, EFileLoggingModeAppend, aDes); |
|
79 } |
|
80 |
|
81 inline void FHex(const TUint8* aPtr, TInt aLen) |
|
82 { |
|
83 RFileLogger::HexDump(KMEBLogDir, KMEBLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen); |
|
84 } |
|
85 |
|
86 inline void FHex(const TDesC8& aDes) |
|
87 { |
|
88 FHex(aDes.Ptr(), aDes.Length()); |
|
89 } |
|
90 |
|
91 inline void FCreate() |
|
92 { |
|
93 TFileName path(_L("c:\\logs\\")); |
|
94 path.Append(KMEBLogDir); |
|
95 path.Append(_L("\\")); |
|
96 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
97 fs.MkDirAll(path); |
|
98 RFileLogger::WriteFormat(KMEBLogDir, KMEBLogFile, EFileLoggingModeOverwrite, KMEBLogBanner); |
|
99 } |
|
100 |
|
101 #endif // USE_RDEBUG |
|
102 |
|
103 #else // not _DEBUG |
|
104 |
|
105 inline void FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) {}; |
|
106 |
|
107 #define MEBLOGGER_CREATE |
|
108 #define MEBLOGGER_DELETE |
|
109 #define MEBLOGGER_ENTERFN(a) |
|
110 #define MEBLOGGER_LEAVEFN(a) |
|
111 #define MEBLOGGER_WRITE(a) |
|
112 #define MEBLOGGER_WRITEF 1 ? ((void)0) : FPrint |
|
113 #define MEBLOGGER_WRITE_TIMESTAMP(a) |
|
114 |
|
115 #endif // _DEBUG |
|
116 |
|
117 #endif // MSGEDITORLOGGING_H |
|
118 |
|
119 // End of File |