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: Haptics conn plugin debug trace macro definition header file. |
|
15 * |
|
16 */ |
|
17 #ifndef HAPTICSCONNTRACE_H |
|
18 #define HAPTICSCONNTRACE_H |
|
19 |
|
20 #include <bldvariant.hrh> |
|
21 #include <e32svr.h> |
|
22 #include <e32std.h> |
|
23 #include <e32svr.h> |
|
24 #include <flogger.h> |
|
25 |
|
26 /** |
|
27 * Writes formatted string data to a file using RFileLogger. |
|
28 * |
|
29 * @param aFmt Value-referenced descriptor containing the formatted string. |
|
30 */ |
|
31 inline void HwrmWriteFormat( TRefByValue<const TDesC> aFmt, ... ) |
|
32 { |
|
33 _LIT( KDir, "Hwrm" ); |
|
34 _LIT( KName, "Hwres.log" ); |
|
35 |
|
36 // take the ellipsis parameters |
|
37 VA_LIST args; |
|
38 VA_START( args, aFmt ); |
|
39 RFileLogger::WriteFormat( KDir, KName, EFileLoggingModeAppend, aFmt, args ); |
|
40 VA_END( args ); |
|
41 } |
|
42 |
|
43 /** |
|
44 * Writes data dump in hex format in "[ 00 01 FF ]" style. |
|
45 * |
|
46 * @param aPrefix Descriptor containing the string to be appended in |
|
47 * front of the actual data dump. |
|
48 * @param aData An 8-bit descriptor containing the data buffer for which |
|
49 * the data dump is written. |
|
50 */ |
|
51 inline void DataDumpTrace( const TDesC& aPrefix, const TDesC8& aData ) |
|
52 { |
|
53 _LIT( KSATraceDataDumpStart, " [ " ); |
|
54 _LIT( KSATraceDataDumpLineAlign, " " ); |
|
55 _LIT( KSATraceDataDumpStop, " ] " ); |
|
56 _LIT( KSATraceDataDumpValue, "%02x " ); |
|
57 const TInt KSASDataDumpTraceBytesPerLine = 10; |
|
58 |
|
59 HBufC* buffer = HBufC::New( 255 ); |
|
60 |
|
61 if ( buffer != NULL ) |
|
62 { |
|
63 buffer->Des().Copy( aPrefix ); |
|
64 buffer->Des().Append( KSATraceDataDumpStart ); |
|
65 for ( TInt i = 0; i < aData.Length(); i++) |
|
66 { |
|
67 buffer->Des().AppendFormat( KSATraceDataDumpValue, aData[i] ); |
|
68 |
|
69 if( ( i % KSASDataDumpTraceBytesPerLine == ( KSASDataDumpTraceBytesPerLine - 1 ) ) && |
|
70 ( i + 1 < aData.Length() ) ) |
|
71 { |
|
72 RDebug::Print( buffer->Des() ); |
|
73 |
|
74 buffer->Des().Copy( aPrefix); |
|
75 buffer->Des().Append( KSATraceDataDumpLineAlign ); |
|
76 } |
|
77 } |
|
78 buffer->Des().Append( KSATraceDataDumpStop ); |
|
79 |
|
80 RDebug::Print( buffer->Des() ); |
|
81 |
|
82 } |
|
83 |
|
84 delete buffer; |
|
85 } |
|
86 |
|
87 #ifdef _DEBUG |
|
88 |
|
89 #ifdef USE_FILE_LOGGING |
|
90 |
|
91 #define COMPONENT_TRACE( a ) HwrmWriteFormat a |
|
92 #define API_TRACE( a ) HwrmWriteFormat a |
|
93 #define DATADUMP_TRACE( a, b ) |
|
94 |
|
95 #else |
|
96 |
|
97 #define COMPONENT_TRACE( a ) RDebug::Print a |
|
98 #define API_TRACE( a ) RDebug::Print a |
|
99 #define DATADUMP_TRACE( a, b ) DataDumpTrace( a, b ) |
|
100 |
|
101 #endif // #ifdef USE_FILE_LOGGING |
|
102 |
|
103 #else // #ifdef _DEBUG |
|
104 |
|
105 #define COMPONENT_TRACE( a ) |
|
106 #define API_TRACE( a ) |
|
107 #define DATADUMP_TRACE( a, b ) |
|
108 |
|
109 #endif //#ifdef _DEBUG |
|
110 #endif //#ifndef HAPTICSCONNTRACE_H |
|
111 |
|
112 |
|
113 // End of File |
|