|
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: This file defines logging macros for Fotastartupextension log |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef FOTASTARTUPDEBUG_H |
|
22 #define FOTASTARTUPDEBUG_H |
|
23 |
|
24 #include <e32debug.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 //Examples |
|
28 //FLOG( _L( "[fotastartupextensionplugin] CFotaStartupExtensionPlugIn::NewL:" ) ); |
|
29 //FTRACE(RDebug::Print(_L("[fotastartupextensionplugin] fotastartupextensionplugin::NewL: err (%d)"), err)); |
|
30 #ifdef _DEBUG |
|
31 |
|
32 const TInt KBTHexDumpWidth=16; |
|
33 const TInt KBTLogBufferSize=100; |
|
34 const TText KFullStopChar='.'; |
|
35 |
|
36 _LIT(KBTFirstFormatString,"%04x: "); |
|
37 _LIT(KBTSecondFormatString,"%02x "); |
|
38 _LIT(KBTThirdFormatString,"%c"); |
|
39 _LIT(KBTThreeSpaces," "); |
|
40 _LIT(KBTSeparator," "); |
|
41 |
|
42 inline void HexDump(const TUint8* aPtr, TInt aLen) |
|
43 { |
|
44 if( aPtr != NULL ) |
|
45 { |
|
46 TBuf<KBTLogBufferSize> line; |
|
47 TInt i = 0; |
|
48 |
|
49 while (aLen>0) |
|
50 { |
|
51 TInt n = (aLen>KBTHexDumpWidth ? KBTHexDumpWidth : aLen); |
|
52 line.AppendFormat(KBTFirstFormatString,i); |
|
53 TInt j; |
|
54 for (j=0; j<n; j++) |
|
55 line.AppendFormat(KBTSecondFormatString,aPtr[i+j]); |
|
56 while (j++<KBTHexDumpWidth) |
|
57 line.Append(KBTThreeSpaces); |
|
58 line.Append(KBTSeparator); |
|
59 for (j=0; j<n; j++) |
|
60 line.AppendFormat(KBTThirdFormatString,(aPtr[i+j]<32 || aPtr[i+j]>126 || aPtr[i+j]==37) ? KFullStopChar : aPtr[i+j]); |
|
61 |
|
62 RDebug::Print(line); |
|
63 |
|
64 line.Zero(); |
|
65 aLen-=n; |
|
66 i+=n; |
|
67 } |
|
68 } |
|
69 } |
|
70 |
|
71 |
|
72 // =========================================================================== |
|
73 #ifdef __WINS__ // File logging for WINS |
|
74 // =========================================================================== |
|
75 #include <e32std.h> |
|
76 #include <f32file.h> |
|
77 #include <flogger.h> |
|
78 |
|
79 _LIT( KLogFile, "fotacustcmds.log" ); |
|
80 _LIT( KLogDirFullName, "c:\\logs\\" ); |
|
81 _LIT( KLogDir, "fota" ); |
|
82 |
|
83 #define FLOG( a ) { FPrint(a); } |
|
84 #define FTRACE( a ) { a; } |
|
85 |
|
86 // Declare the FPrint function |
|
87 // |
|
88 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... ) |
|
89 { |
|
90 VA_LIST list; |
|
91 VA_START( list, aFmt ); |
|
92 RFileLogger::WriteFormat( KLogDir, |
|
93 KLogFile, |
|
94 EFileLoggingModeAppend, |
|
95 aFmt, |
|
96 list ); |
|
97 } |
|
98 |
|
99 // =========================================================================== |
|
100 #else // RDebug logging for target HW |
|
101 // =========================================================================== |
|
102 /*#include <e32svr.h> |
|
103 |
|
104 #define FLOG( a ) { RDebug::Print( a ); } |
|
105 #define FTRACE( a ) { a; } |
|
106 |
|
107 */ |
|
108 |
|
109 /////////////////////////////// |
|
110 #include <e32std.h> |
|
111 #include <f32file.h> |
|
112 #include <flogger.h> |
|
113 |
|
114 _LIT( KLogFile, "fotacustcmds.log" ); |
|
115 _LIT( KLogDirFullName, "c:\\logs\\" ); |
|
116 _LIT( KLogDir, "fota" ); |
|
117 |
|
118 #define FLOG( a ) { FPrint(a); } |
|
119 #define FTRACE( a ) { a; } |
|
120 |
|
121 // Declare the FPrint function |
|
122 // |
|
123 inline void FPrint( const TRefByValue<const TDesC> aFmt, ... ) |
|
124 { |
|
125 VA_LIST list; |
|
126 VA_START( list, aFmt ); |
|
127 RFileLogger::WriteFormat( KLogDir, |
|
128 KLogFile, |
|
129 EFileLoggingModeAppend, |
|
130 aFmt, |
|
131 list ); |
|
132 } |
|
133 |
|
134 //////////////////////////////// |
|
135 |
|
136 |
|
137 #endif //__WINS__ |
|
138 |
|
139 // =========================================================================== |
|
140 #else // // No loggings --> Reduced binary size |
|
141 // =========================================================================== |
|
142 #define FLOG( a ) |
|
143 #define FTRACE( a ) |
|
144 |
|
145 #endif // _DEBUG |
|
146 |
|
147 ///////// /////////////////////// |
|
148 inline void LOGX(TInt aSource) |
|
149 { |
|
150 HBufC *iMyBufNumber = HBufC::NewLC(255); |
|
151 TPtr bufNumberPtr(iMyBufNumber->Des()); |
|
152 bufNumberPtr.FillZ(); |
|
153 bufNumberPtr.AppendFormat(_L("%d"),aSource); |
|
154 FLOG(iMyBufNumber->Des()); |
|
155 CleanupStack::PopAndDestroy(); |
|
156 } |
|
157 ///////// /////////////////////// |
|
158 |
|
159 #endif // FOTASTARTUP_H |
|
160 |
|
161 // End of File |