|
1 /* |
|
2 * Copyright (c) 2005 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 * Contains logging macros for SmilMediaRenderer.dll. Logging can be enabled from mmp file. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // ========== LOGGING MACROS =============================== |
|
22 |
|
23 #ifndef SMILMEDIALOGGING_H |
|
24 #define SMILMEDIALOGGING_H |
|
25 |
|
26 #ifdef USE_LOGGER |
|
27 |
|
28 #include <e32std.h> |
|
29 #include <e32def.h> |
|
30 #include <flogger.h> |
|
31 |
|
32 #ifdef USE_RDEBUG |
|
33 |
|
34 _LIT(KSMILUILogBanner, "SMILUI"); |
|
35 _LIT(KSMILUILogEnterFn, "SMILUI: >> %S"); |
|
36 _LIT(KSMILUILogLeaveFn, "SMILUI: << %S"); |
|
37 _LIT(KSMILUILogWrite, "SMILUI: %S"); |
|
38 _LIT(KSMILUILogTag, "SMILUI: "); |
|
39 _LIT(KSMILUILogExit, "SMILUI: Application exit"); |
|
40 _LIT(KSMILUILogTimeFormatString, "%H:%T:%S:%*C2 "); |
|
41 |
|
42 #define SMILUILOGGER_CREATE(a) {RDebug::Print(KSMILUILogBanner);} |
|
43 #define SMILUILOGGER_DELETE {RDebug::Print(KSMILUILogExit);} |
|
44 #define SMILUILOGGER_ENTERFN(a) {_LIT(temp, a); RDebug::Print(KSMILUILogEnterFn, &temp);} |
|
45 #define SMILUILOGGER_LEAVEFN(a) {_LIT(temp, a); RDebug::Print(KSMILUILogLeaveFn, &temp);} |
|
46 #define SMILUILOGGER_WRITE(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KSMILUILogTimeFormatString );buffer.Append(temp); buffer.Insert(0, KSMILUILogTag); RDebug::Print(buffer); } |
|
47 //#define SMILUILOGGER_WRITE(a) {_LIT(temp, a); RDebug::Print(KSMILUILogWrite, &temp);} |
|
48 #define SMILUILOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KSMILUILogTimeFormatString ); buffer.Insert(0, temp); buffer.Insert(0, KSMILUILogTag); RDebug::Print(buffer); } |
|
49 #define SMILUILOGGER_WRITEF RDebug::Print |
|
50 |
|
51 #else |
|
52 |
|
53 _LIT( KSMILUILogDir, "smilui"); |
|
54 _LIT( KSMILUILogFile, "smilui.txt"); |
|
55 _LIT8(KSMILUILogBanner, "SMILUI"); |
|
56 _LIT8(KSMILUILogEnterFn, "SMILUI: >> %S"); |
|
57 _LIT8(KSMILUILogLeaveFn, "SMILUI: << %S"); |
|
58 _LIT8(KSMILUILogExit, "SMILUI: Application exit"); |
|
59 _LIT( KSMILUILogTimeFormatString, "%H:%T:%S:%*C2 "); |
|
60 |
|
61 #define SMILUILOGGER_CREATE(a) {FCreate(a);} |
|
62 #define SMILUILOGGER_DELETE {RFileLogger::Write(KSMILUILogDir, KSMILUILogFile, EFileLoggingModeAppend, KSMILUILogExit);} |
|
63 #define SMILUILOGGER_ENTERFN(a) {_LIT8(temp, a); RFileLogger::WriteFormat(KSMILUILogDir, KSMILUILogFile, EFileLoggingModeAppend, KSMILUILogEnterFn, &temp);} |
|
64 #define SMILUILOGGER_LEAVEFN(a) {_LIT8(temp, a); RFileLogger::WriteFormat(KSMILUILogDir, KSMILUILogFile, EFileLoggingModeAppend, KSMILUILogLeaveFn, &temp);} |
|
65 #define SMILUILOGGER_WRITE(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KSMILUILogTimeFormatString ); buffer.Append(temp); RFileLogger::Write(KSMILUILogDir, KSMILUILogFile, EFileLoggingModeAppend, buffer); } |
|
66 //#define SMILUILOGGER_WRITE(a) {_LIT(temp, a); RFileLogger::Write(KSMILUILogDir, KSMILUILogFile, EFileLoggingModeAppend, temp);} |
|
67 #define SMILUILOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KSMILUILogTimeFormatString ); buffer.Insert(0, temp); RFileLogger::Write(KSMILUILogDir, KSMILUILogFile, EFileLoggingModeAppend, buffer); } |
|
68 #define SMILUILOGGER_WRITEF FPrint |
|
69 |
|
70 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...) |
|
71 { |
|
72 VA_LIST list; |
|
73 VA_START(list,aFmt); |
|
74 RFileLogger::WriteFormat(KSMILUILogDir, KSMILUILogFile, EFileLoggingModeAppend, aFmt, list); |
|
75 } |
|
76 |
|
77 inline void FPrint(const TDesC& aDes) |
|
78 { |
|
79 RFileLogger::WriteFormat(KSMILUILogDir, KSMILUILogFile, EFileLoggingModeAppend, aDes); |
|
80 } |
|
81 |
|
82 inline void FHex(const TUint8* aPtr, TInt aLen) |
|
83 { |
|
84 RFileLogger::HexDump(KSMILUILogDir, KSMILUILogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen); |
|
85 } |
|
86 |
|
87 inline void FHex(const TDesC8& aDes) |
|
88 { |
|
89 FHex(aDes.Ptr(), aDes.Length()); |
|
90 } |
|
91 |
|
92 inline void FCreate(RFs& aFs) |
|
93 { |
|
94 TFileName path(_L("c:\\logs\\")); |
|
95 path.Append(KSMILUILogDir); |
|
96 path.Append(_L("\\")); |
|
97 aFs.MkDirAll(path); |
|
98 RFileLogger::WriteFormat(KSMILUILogDir, KSMILUILogFile, EFileLoggingModeOverwrite, KSMILUILogBanner); |
|
99 } |
|
100 |
|
101 #endif // USE_RDEBUG |
|
102 |
|
103 #else // USE_LOGGER |
|
104 |
|
105 // dummy inline FPrint for SMILUILOGGER_WRITEF macro. |
|
106 inline TInt FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { return 0; } |
|
107 |
|
108 #define SMILUILOGGER_CREATE(a) |
|
109 #define SMILUILOGGER_DELETE |
|
110 #define SMILUILOGGER_ENTERFN(a) |
|
111 #define SMILUILOGGER_LEAVEFN(a) |
|
112 #define SMILUILOGGER_WRITE(a) |
|
113 // if USE_LOGGER not defined this call to FPrint gets optimized away. |
|
114 #define SMILUILOGGER_WRITEF 1 ? 0 : FPrint |
|
115 #define SMILUILOGGER_WRITE_TIMESTAMP(a) |
|
116 |
|
117 #endif // USE_LOGGER |
|
118 |
|
119 #endif // SMILMEDIALOGGING_H |
|
120 |
|
121 // ========================================================= |