|
1 /* |
|
2 * Copyright (c) 2005-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: Unified Message Editor logging macros. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef UNIEDITORLOGGING_H |
|
21 #define UNIEDITORLOGGING_H |
|
22 |
|
23 // ========== LOGGING MACROS =============================== |
|
24 |
|
25 #if defined( _DEBUG ) || defined( USE_LOGGER ) |
|
26 |
|
27 #ifndef USE_LOGGER |
|
28 #define USE_LOGGER |
|
29 #endif |
|
30 |
|
31 #include <e32std.h> |
|
32 #include <e32def.h> |
|
33 #include <eikenv.h> |
|
34 #include <flogger.h> |
|
35 |
|
36 #ifdef USE_RDEBUG |
|
37 |
|
38 _LIT( KUNILogBanner, "UNI " ); |
|
39 _LIT( KUNILogEnterFn, "UNI: enter --> %S" ); |
|
40 _LIT( KUNILogLeaveFn, "UNI: leave <-- %S" ); |
|
41 _LIT( KMEBLogWrite, "UNI: %S" ); |
|
42 _LIT( KMEBLogTag, "UNI: " ); |
|
43 _LIT( KUNILogExit, "UNI: Application exit" ); |
|
44 _LIT( KUNILogTimeFormatString, "%H:%T:%S:%*C2" ); |
|
45 |
|
46 #define UNILOGGER_CREATE {RDebug::Print(KUNILogBanner);} |
|
47 #define UNILOGGER_DELETE {RDebug::Print(KUNILogExit);} |
|
48 #define UNILOGGER_ENTERFN(a) {_LIT(unilogger, a); RDebug::Print(KUNILogEnterFn, &unilogger);} |
|
49 #define UNILOGGER_LEAVEFN(a) {_LIT(unilogger, a); RDebug::Print(KUNILogLeaveFn, &unilogger);} |
|
50 #define UNILOGGER_WRITE(a) {_LIT(unilogger, a); RDebug::Print(KUNILogWrite, &unilogger);} |
|
51 #define UNILOGGER_WRITE_TIMESTAMP(a) {_LIT(unilogger, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KUNILogTimeFormatString ); buffer.Insert(0, unilogger); buffer.Insert(0, KUNILogTag); RDebug::Print(buffer); } |
|
52 #define UNILOGGER_WRITEF RDebug::Print |
|
53 #define UNILOGGER_WRITEF8 RDebug::Print |
|
54 |
|
55 #else // USE_RDEBUG |
|
56 |
|
57 _LIT( KUNILogDir, "UNI"); |
|
58 _LIT( KUNILogFile, "UNI.txt"); |
|
59 _LIT8(KUNILogBanner, "UNI "); |
|
60 _LIT8(KUNILogEnterFn, "UNI: -> %S"); |
|
61 _LIT8(KUNILogLeaveFn, "UNI: <- %S"); |
|
62 _LIT8(KUNILogExit, "UNI: Application exit"); |
|
63 _LIT( KUNILogTimeFormatString, "%H:%T:%S:%*C2"); |
|
64 |
|
65 #define UNILOGGER_CREATE {FCreate();} |
|
66 #define UNILOGGER_DELETE {RFileLogger::Write(KUNILogDir, KUNILogFile, EFileLoggingModeAppend, KUNILogExit);} |
|
67 #define UNILOGGER_ENTERFN(a) {_LIT8(unilogger, a); RFileLogger::WriteFormat(KUNILogDir, KUNILogFile, EFileLoggingModeAppend, KUNILogEnterFn, &unilogger);} |
|
68 #define UNILOGGER_LEAVEFN(a) {_LIT8(unilogger, a); RFileLogger::WriteFormat(KUNILogDir, KUNILogFile, EFileLoggingModeAppend, KUNILogLeaveFn, &unilogger);} |
|
69 #define UNILOGGER_WRITE(a) {_LIT(unilogger, a); RFileLogger::Write(KUNILogDir, KUNILogFile, EFileLoggingModeAppend, unilogger);} |
|
70 #define UNILOGGER_WRITE_TIMESTAMP(a) {_LIT(unilogger, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KUNILogTimeFormatString ); buffer.Insert(0, unilogger); RFileLogger::Write(KUNILogDir, KUNILogFile, EFileLoggingModeAppend, buffer); } |
|
71 #define UNILOGGER_WRITEF FPrint |
|
72 #define UNILOGGER_WRITEF8 FPrint8 |
|
73 |
|
74 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...) |
|
75 { |
|
76 VA_LIST list; |
|
77 VA_START(list,aFmt); |
|
78 RFileLogger::WriteFormat(KUNILogDir, KUNILogFile, EFileLoggingModeAppend, aFmt, list); |
|
79 } |
|
80 |
|
81 |
|
82 inline void FPrint8(const TRefByValue<const TDesC8> aFmt, ...) |
|
83 { |
|
84 VA_LIST list; |
|
85 VA_START(list,aFmt); |
|
86 RFileLogger::WriteFormat(KUNILogDir, KUNILogFile, EFileLoggingModeAppend, aFmt, list); |
|
87 } |
|
88 |
|
89 |
|
90 inline void FPrint(const TDesC& aDes) |
|
91 { |
|
92 RFileLogger::WriteFormat(KUNILogDir, KUNILogFile, EFileLoggingModeAppend, aDes); |
|
93 } |
|
94 |
|
95 inline void FHex(const TUint8* aPtr, TInt aLen) |
|
96 { |
|
97 RFileLogger::HexDump(KUNILogDir, KUNILogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen); |
|
98 } |
|
99 |
|
100 inline void FHex(const TDesC8& aDes) |
|
101 { |
|
102 FHex(aDes.Ptr(), aDes.Length()); |
|
103 } |
|
104 |
|
105 inline void FCreate() |
|
106 { |
|
107 TFileName path(_L("c:\\logs\\")); |
|
108 path.Append(KUNILogDir); |
|
109 path.Append(_L("\\")); |
|
110 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
111 fs.MkDirAll(path); |
|
112 RFileLogger::WriteFormat(KUNILogDir, KUNILogFile, EFileLoggingModeOverwrite, KUNILogBanner); |
|
113 } |
|
114 |
|
115 #endif // USE_RDEBUG |
|
116 |
|
117 #else // not logging |
|
118 |
|
119 inline void FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) {}; |
|
120 inline void FPrint8(const TRefByValue<const TDesC8> /*aFmt*/, ...) {}; |
|
121 |
|
122 #define UNILOGGER_CREATE |
|
123 #define UNILOGGER_DELETE |
|
124 #define UNILOGGER_ENTERFN(a) |
|
125 #define UNILOGGER_LEAVEFN(a) |
|
126 #define UNILOGGER_WRITE(a) |
|
127 #define UNILOGGER_WRITEF 1 ? ((void)0) : FPrint |
|
128 #define UNILOGGER_WRITEF8 1 ? ((void)0) : FPrint8 |
|
129 #define UNILOGGER_WRITE_TIMESTAMP(a) |
|
130 |
|
131 #endif // logging |
|
132 |
|
133 #endif // UNIEDITORLOGGING_H |
|
134 |
|
135 // End of File |