|
1 /* |
|
2 * Copyright (c) 2009 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: BmpAnimScrPlugin utilities collection |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef BMPANIMUTILS_H |
|
21 #define BMPANIMUTILS_H |
|
22 |
|
23 // ========== LOGGING MACROS =============================== |
|
24 |
|
25 #ifdef USE_LOGGER |
|
26 |
|
27 #include <e32std.h> |
|
28 #include <e32def.h> |
|
29 #include <eikenv.h> |
|
30 #include <flogger.h> |
|
31 |
|
32 |
|
33 /* logging macros usage: |
|
34 |
|
35 // set logging on in mmp file... |
|
36 MACRO USE_LOGGER |
|
37 #ifdef WINS |
|
38 MACRO USE_RDEBUG |
|
39 #endif |
|
40 |
|
41 |
|
42 void CTestAppUi::ConstructL() |
|
43 { |
|
44 // creates log directory and log file on app startup. |
|
45 // prints starting banner... |
|
46 BMALOGGER_CREATE; |
|
47 |
|
48 // entering to function... |
|
49 BMALOGGER_ENTERFN("ConstructL()"); |
|
50 |
|
51 TInt number = 42; |
|
52 TFileName file; |
|
53 file = "something" .... |
|
54 |
|
55 // print variable number of parameters... |
|
56 // Note: use _L macro for format string! |
|
57 BMALOGGER_WRITEF(_L("BMA: number = %d, file = %S"), number, &file); |
|
58 |
|
59 // print just a string (no _L macro here!) |
|
60 BMALOGGER_WRITE("Hello world!"); |
|
61 |
|
62 // leave from function... |
|
63 BMALOGGER_LEAVEFN("ConstructL()"); |
|
64 } |
|
65 |
|
66 CTestAppUi::~CTestAppUi() |
|
67 { |
|
68 // print app exit banner when application exits. |
|
69 BMALOGGER_DELETE; |
|
70 } |
|
71 |
|
72 */ |
|
73 |
|
74 #ifdef USE_RDEBUG |
|
75 |
|
76 _LIT(KBMALogBanner, "BmpAnim log start"); |
|
77 _LIT(KBMALogEnterFn, "BMA: enter --> %S"); |
|
78 _LIT(KBMALogLeaveFn, "BMA: leave <-- %S"); |
|
79 _LIT(KBMALogWrite, "BMA: %S"); |
|
80 _LIT(KBMALogTag, "BMA: "); |
|
81 _LIT(KBMALogExit, "BmpAnim log end"); |
|
82 _LIT(KBMALogTimeFormatString, "%H:%T:%S:%*C2"); |
|
83 |
|
84 #define BMALOGGER_CREATE {RDebug::Print(KBMALogBanner);} |
|
85 #define BMALOGGER_DELETE {RDebug::Print(KBMALogExit);} |
|
86 #define BMALOGGER_ENTERFN(a) {_LIT(temp, a); RDebug::Print(KBMALogEnterFn, &temp);} |
|
87 #define BMALOGGER_LEAVEFN(a) {_LIT(temp, a); RDebug::Print(KBMALogLeaveFn, &temp);} |
|
88 #define BMALOGGER_WRITE(a) {_LIT(temp, a); RDebug::Print(KBMALogWrite, &temp);} |
|
89 #define BMALOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL(buffer, KBMALogTimeFormatString); buffer.Insert(0, temp); buffer.Insert(0, KBMALogTag); RDebug::Print(buffer); } |
|
90 #define BMALOGGER_WRITEF RDebug::Print |
|
91 |
|
92 #else // !USE_RDEBUG |
|
93 |
|
94 _LIT(KBMALogDir, "BMA"); |
|
95 _LIT(KBMALogFile, "BMA.txt"); |
|
96 _LIT8(KBMALogBanner, "BmpAnim log start"); |
|
97 _LIT8(KBMALogEnterFn, "BMA: -> %S"); |
|
98 _LIT8(KBMALogLeaveFn, "BMA: <- %S"); |
|
99 _LIT8(KBMALogExit, "BmpAnim log end"); |
|
100 _LIT(KBMALogTimeFormatString, "%H:%T:%S:%*C2"); |
|
101 |
|
102 #define BMALOGGER_CREATE {FCreate();} |
|
103 #define BMALOGGER_DELETE {RFileLogger::Write(KBMALogDir, KBMALogFile, EFileLoggingModeAppend, KBMALogExit);} |
|
104 #define BMALOGGER_ENTERFN(a) {_LIT8(temp, a); RFileLogger::WriteFormat(KBMALogDir, KBMALogFile, EFileLoggingModeAppend, KBMALogEnterFn, &temp);} |
|
105 #define BMALOGGER_LEAVEFN(a) {_LIT8(temp, a); RFileLogger::WriteFormat(KBMALogDir, KBMALogFile, EFileLoggingModeAppend, KBMALogLeaveFn, &temp);} |
|
106 #define BMALOGGER_WRITE(a) {_LIT(temp, a); RFileLogger::Write(KBMALogDir, KBMALogFile, EFileLoggingModeAppend, temp);} |
|
107 #define BMALOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL(buffer, KBMALogTimeFormatString); buffer.Insert(0, temp); RFileLogger::Write(KBMALogDir, KBMALogFile, EFileLoggingModeAppend, buffer); } |
|
108 #define BMALOGGER_WRITEF FPrint |
|
109 |
|
110 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...) |
|
111 { |
|
112 VA_LIST list; |
|
113 VA_START(list, aFmt); |
|
114 RFileLogger::WriteFormat(KBMALogDir, KBMALogFile, EFileLoggingModeAppend, aFmt, list); |
|
115 } |
|
116 |
|
117 inline void FPrint(const TDesC& aDes) |
|
118 { |
|
119 RFileLogger::WriteFormat(KBMALogDir, KBMALogFile, EFileLoggingModeAppend, aDes); |
|
120 } |
|
121 |
|
122 inline void FHex(const TUint8* aPtr, TInt aLen) |
|
123 { |
|
124 RFileLogger::HexDump(KBMALogDir, KBMALogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen); |
|
125 } |
|
126 |
|
127 inline void FHex(const TDesC8& aDes) |
|
128 { |
|
129 FHex(aDes.Ptr(), aDes.Length()); |
|
130 } |
|
131 |
|
132 inline void FCreate() |
|
133 { |
|
134 #ifdef RD_PF_SEC_APPARC |
|
135 // Use screensaver private dir |
|
136 TFileName path(_L("c:\\private\\100056cf\\")); |
|
137 #else |
|
138 TFileName path(_L("c:\\logs\\")); |
|
139 #endif |
|
140 path.Append(KBMALogDir); |
|
141 path.Append(_L("\\")); |
|
142 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
143 fs.MkDirAll(path); |
|
144 RFileLogger::WriteFormat(KBMALogDir, KBMALogFile, EFileLoggingModeOverwrite, KBMALogBanner); |
|
145 } |
|
146 |
|
147 #endif // !USE_RDEBUG |
|
148 |
|
149 #else // !USE_LOGGER |
|
150 |
|
151 inline void FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { }; |
|
152 |
|
153 #define BMALOGGER_CREATE |
|
154 #define BMALOGGER_DELETE |
|
155 #define BMALOGGER_ENTERFN(a) |
|
156 #define BMALOGGER_LEAVEFN(a) |
|
157 #define BMALOGGER_WRITE(a) |
|
158 #define BMALOGGER_WRITEF 1 ? ((void)0) : FPrint |
|
159 #define BMALOGGER_WRITE_TIMESTAMP(a) |
|
160 |
|
161 #endif // USE_LOGGER |
|
162 |
|
163 #endif // BMPANIMUTILS_H |
|
164 |