|
1 /* |
|
2 * Copyright (c) 2006 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: Declaration of logger |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CONNECTIONMETHODLOGGER_H |
|
19 #define CONNECTIONMETHODLOGGER_H |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32svr.h> |
|
23 |
|
24 #ifdef _DEBUG |
|
25 |
|
26 #define __CONNECTION_METHOD_LOG__ |
|
27 #include <flogger.h> |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 class CFunctionEntryExit; |
|
32 |
|
33 //Logging to file in THUMB UDEB |
|
34 class TLogger |
|
35 { |
|
36 public: // methods |
|
37 |
|
38 static void CreateLogger( TAny* aOwner ); |
|
39 static void CloseLogger( TAny* aOwner ); |
|
40 |
|
41 static void AttachLogger( const TAny* aOwner, |
|
42 const TAny* aAttach1, |
|
43 const TAny* aAttach2 ); |
|
44 |
|
45 static void NameIt( const TAny* aOwner, |
|
46 TRefByValue<const TDesC> aNameFmt, |
|
47 ... ); |
|
48 |
|
49 static void LogIt( const TAny* aOwner, |
|
50 TRefByValue<const TDesC> aFmt, |
|
51 ... ); |
|
52 static void LogIt( const TAny* aOwner, |
|
53 TRefByValue<const TDesC8> aFmt, |
|
54 ... ); |
|
55 static void LogIt( const TAny* aOwner, |
|
56 TRefByValue<const TDesC> aFmt, |
|
57 VA_LIST aList ); |
|
58 static void LogIt( const TAny* aOwner, |
|
59 TRefByValue<const TDesC8> aFmt, |
|
60 VA_LIST aList ); |
|
61 |
|
62 private: |
|
63 |
|
64 TBuf<2048> iLogBuf; |
|
65 TBuf8<2048> iLogBuf8; |
|
66 TInt iRefCounter; |
|
67 TAny* iOwner; |
|
68 }; |
|
69 |
|
70 NONSHARABLE_CLASS( CFunctionEntryExit ): public CBase |
|
71 { |
|
72 public: |
|
73 |
|
74 CFunctionEntryExit( const TAny* aOwner, |
|
75 TRefByValue<const TDesC> aFunc ); |
|
76 ~CFunctionEntryExit(); |
|
77 |
|
78 public: |
|
79 |
|
80 TPtrC iFunc; // function name |
|
81 const TAny* iOwner; |
|
82 TTime iEntryTime; |
|
83 }; |
|
84 |
|
85 #define LOGGER_ENTERFN( a ) CFunctionEntryExit entryExit( this, _L(a) ); |
|
86 #define CLOG_ENTERFN_PTR( a ) CFunctionEntryExit entryExit( NULL, _L(a) ); |
|
87 |
|
88 #define CLOG_CREATE TLogger::CreateLogger( this ); |
|
89 #define CLOG_CREATE_PTR TLogger::CreateLogger( NULL ); |
|
90 #define CLOG_ATTACH( attach1, attach2 ) TLogger::AttachLogger( this, \ |
|
91 attach1, \ |
|
92 attach2 ); |
|
93 #define CLOG_NAME( a ) TLogger::NameIt( this, a ); |
|
94 #define CLOG_NAME_1( a, b ) TLogger::NameIt( this, a, b ); |
|
95 #define CLOG_NAME_2( a, b, c ) TLogger::NameIt( this, a, b, c ); |
|
96 #define CLOG_NAME_3( a, b, c, d ) TLogger::NameIt( this, a, b, c, d ); |
|
97 #define CLOG_CLOSE TLogger::CloseLogger( this ); |
|
98 #define CLOG_WRITE( a ) TLogger::LogIt( this, _L(a) ); |
|
99 #define CLOG_WRITE_FORMAT( a, b ) TLogger::LogIt( this, _L(a), b ); |
|
100 #define CLOG_WRITE_1( a, b ) TLogger::LogIt( this, _L(a), b ); |
|
101 #define CLOG_WRITE_2( a, b, c ) TLogger::LogIt( this, _L(a), b, c ); |
|
102 #define CLOG_WRITE_3( a, b, c, d ) TLogger::LogIt( this, _L(a), b, c, d ); |
|
103 #define CLOG_WRITE_4( a, b, c, d, e ) TLogger::LogIt( this, \ |
|
104 _L(a), b, c, d, e ); |
|
105 #define CLOG_WRITE8( a ) TLogger::LogIt( this, _L8(a) ); |
|
106 #define CLOG_WRITE8_1( a, b ) TLogger::LogIt( this, _L8(a), b ); |
|
107 #define CLOG_WRITE8_2( a, b, c ) TLogger::LogIt( this, _L8(a), b, c ); |
|
108 #define CLOG_WRITE8_3( a, b, c, d ) TLogger::LogIt( this, _L8(a), b, c, d ); |
|
109 #define CLOG_WRITE8_4( a, b, c, d, e ) TLogger::LogIt( this, \ |
|
110 _L8(a), b, c, d, e ); |
|
111 |
|
112 #define CLOG_NAME_PTR( ptr, a ) TLogger::NameIt( ptr, a ); |
|
113 #define CLOG_ATTACH_PTR( ptr, attach1, attach2 ) TLogger::AttachLogger( \ |
|
114 ptr, attach1, attach2 ); |
|
115 #define CLOG_WRITE_PTR( ptr, a ) TLogger::LogIt( ptr, \ |
|
116 _L(a) ); |
|
117 #define CLOG_WRITE_1_PTR( ptr, a, b ) TLogger::LogIt( ptr, \ |
|
118 _L(a), b ); |
|
119 #define CLOG_WRITE_2_PTR( ptr, a, b, c ) TLogger::LogIt( ptr, \ |
|
120 _L(a), b, c ); |
|
121 #define CLOG_WRITE_3_PTR( ptr, a, b, c, d ) TLogger::LogIt( ptr, \ |
|
122 _L(a), b, c, d ); |
|
123 #define CLOG_WRITE_4_PTR( ptr, a, b, c, d, e ) TLogger::LogIt( ptr, \ |
|
124 _L(a), b, c, d, e ); |
|
125 #define CLOG_WRITE_FORMAT_PTR( ptr, a, b ) TLogger::LogIt( ptr, \ |
|
126 _L(a), b ); |
|
127 #define CLOG_CLOSE_PTR( ptr ) TLogger::CloseLogger( ptr ); |
|
128 |
|
129 #else // _DEBUG |
|
130 |
|
131 #define LOGGER_ENTERFN( a ) |
|
132 #define CLOG_ENTERFN_PTR( a ) |
|
133 |
|
134 #define CLOG_CREATE |
|
135 #define CLOG_CREATE_PTR |
|
136 #define CLOG_ATTACH( attach1, attach2 ) |
|
137 #define CLOG_NAME( a ) |
|
138 #define CLOG_NAME_1( a, b ) |
|
139 #define CLOG_NAME_2( a, b, c ) |
|
140 #define CLOG_NAME_3( a, b, c, d ) |
|
141 #define CLOG_CLOSE |
|
142 #define CLOG_WRITE( a ) |
|
143 #define CLOG_WRITE_FORMAT( a, b ) |
|
144 #define CLOG_WRITE_1( a, b ) |
|
145 #define CLOG_WRITE_2( a, b, c ) |
|
146 #define CLOG_WRITE_3( a, b, c, d ) |
|
147 #define CLOG_WRITE_4( a, b, c, d, e ) |
|
148 #define CLOG_WRITE8( a ) |
|
149 #define CLOG_WRITE8_1( a, b ) |
|
150 #define CLOG_WRITE8_2( a, b, c ) |
|
151 #define CLOG_WRITE8_3( a, b, c, d ) |
|
152 #define CLOG_WRITE8_4( a, b, c, d, e ) |
|
153 |
|
154 #define CLOG_NAME_PTR( ptr, a ) |
|
155 #define CLOG_ATTACH_PTR( ptr, attach1, attach2 ) |
|
156 #define CLOG_WRITE_PTR( ptr, a ) |
|
157 #define CLOG_WRITE_1_PTR( ptr, a, b ) |
|
158 #define CLOG_WRITE_2_PTR( ptr, a, b, c ) |
|
159 #define CLOG_WRITE_3_PTR( ptr, a, b, c, d ) |
|
160 #define CLOG_WRITE_4_PTR( ptr, a, b, c, d, e ) |
|
161 #define CLOG_WRITE_FORMAT_PTR( ptr, a, b ) |
|
162 #define CLOG_CLOSE_PTR( ptr ) |
|
163 |
|
164 #endif // _DEBUG |
|
165 #endif // CONNECTIONMETHODLOGGER_H |