1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // FLogger Client side header |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 |
|
26 |
|
27 #ifndef __FLOGGER_H__ |
|
28 #define __FLOGGER_H__ |
|
29 |
|
30 #include <e32base.h> |
|
31 |
|
32 /** Maximum log buffer size. |
|
33 @internalTechnology */ |
|
34 const TInt KLogBufferSize=150; |
|
35 |
|
36 // [All of this start up stuff copied from DBMS] |
|
37 |
|
38 class FLogger |
|
39 /** Controls the flogger server. |
|
40 @internalComponent */ |
|
41 { |
|
42 public: |
|
43 class TSignal |
|
44 /** |
|
45 @internalComponent |
|
46 */ |
|
47 { |
|
48 friend class FLogger; |
|
49 public: |
|
50 inline TSignal() {} |
|
51 inline TInt Set(const TDesC& aCommand); |
|
52 |
|
53 inline TSignal(TRequestStatus& aStatus); |
|
54 |
|
55 inline TPtrC Command() const; |
|
56 |
|
57 private: |
|
58 TRequestStatus* iStatus; |
|
59 TThreadId iId; |
|
60 }; |
|
61 public: |
|
62 static TInt Start(); |
|
63 |
|
64 IMPORT_C static TInt Run(TSignal& aSignal); |
|
65 |
|
66 private: |
|
67 static TInt Init(); |
|
68 }; |
|
69 |
|
70 |
|
71 /** The mode used to write to the log file. |
|
72 @internalTechnology */ |
|
73 enum TFileLoggingMode |
|
74 { |
|
75 /** Log file mode has not been explicitly set. */ |
|
76 EFileLoggingModeUnknown =0, |
|
77 /** Open the log file in append mode. */ |
|
78 EFileLoggingModeAppend, |
|
79 /** Open the log file in overwrite mode. */ |
|
80 EFileLoggingModeOverwrite, |
|
81 EFileLoggingModeAppendRaw, |
|
82 EFileLoggingModeOverwriteRaw |
|
83 }; |
|
84 |
|
85 NONSHARABLE_CLASS(TLogFormatter16Overflow) :public TDes16Overflow |
|
86 /** Unicode overflow handler. |
|
87 @internalComponent */ |
|
88 { |
|
89 public: |
|
90 virtual void Overflow(TDes16& aDes); |
|
91 }; |
|
92 |
|
93 NONSHARABLE_CLASS(TLogFormatter8Overflow) :public TDes8Overflow |
|
94 /** Overflow handler. |
|
95 @internalComponent */ |
|
96 { |
|
97 public: |
|
98 virtual void Overflow(TDes8& aDes); |
|
99 }; |
|
100 |
|
101 class TLogFormatter |
|
102 /** Formatting methods for log file data. |
|
103 @internalComponent */ |
|
104 { |
|
105 public: |
|
106 TLogFormatter(); |
|
107 void SetDateAndTime(TBool aUseDate,TBool aUseTime); |
|
108 TInt FormatTextToWritableBuffer(TDes8& aBuf, const TDesC16& aText) const; |
|
109 TInt FormatTextToWritableBuffer(TDes8& aBuf, const TDesC8& aText) const; |
|
110 TInt ConvertToWritableBuffer(TDes8& aBuf, TRefByValue<const TDesC16> aFmt, VA_LIST& aList); |
|
111 TInt ConvertToWritableBuffer(TDes8& aBuf, TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
112 private: |
|
113 void GetDateAndTimeL(TDes& aDate, TDes& aTime) const; |
|
114 void WriteL(TDes8& aTrg, const TDesC16& aSrc) const; |
|
115 void WriteL(TDes8& aTrg, const TDesC8& aSrc) const; |
|
116 private: |
|
117 TBool iUseDate; |
|
118 TBool iUseTime; |
|
119 TLogFormatter16Overflow iOverflow16; |
|
120 TLogFormatter8Overflow iOverflow8; |
|
121 }; |
|
122 |
|
123 class TLogFile |
|
124 /** General access to packaged log files. |
|
125 @internalComponent */ |
|
126 { |
|
127 public: |
|
128 TLogFile(); |
|
129 TLogFile(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode); |
|
130 TBool operator==(const TLogFile& aLogFile) const; |
|
131 void Set(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode); |
|
132 inline TBool Valid() const; |
|
133 inline TFileName Directory() const; |
|
134 inline TFileName Name() const; |
|
135 inline TFileLoggingMode Mode() const; |
|
136 inline void SetValid(TBool aValid); |
|
137 private: |
|
138 TBool iValid; |
|
139 TFileName iDirectory; |
|
140 TFileName iName; |
|
141 TFileLoggingMode iMode; |
|
142 }; |
|
143 |
|
144 #include <flogger.inl> |
|
145 |
|
146 class RFileLogger : public RSessionBase |
|
147 /** Provides access methods to file logging. |
|
148 |
|
149 The file logger API contains both static and non-static versions of access |
|
150 functions to the file logging system. |
|
151 @internalTechnology */ |
|
152 { |
|
153 public: |
|
154 IMPORT_C RFileLogger(); |
|
155 IMPORT_C ~RFileLogger(); |
|
156 IMPORT_C TVersion Version() const; |
|
157 IMPORT_C TInt Connect(); |
|
158 IMPORT_C void SetDateAndTime(TBool aUseDate,TBool aUseTime); |
|
159 IMPORT_C void CreateLog(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode); |
|
160 IMPORT_C void CloseLog(); |
|
161 IMPORT_C void Write(const TDesC16& aText); |
|
162 IMPORT_C void WriteFormat(TRefByValue<const TDesC16> aFmt,...); |
|
163 IMPORT_C void WriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList); |
|
164 IMPORT_C void Write(const TDesC8& aText); |
|
165 IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt,...); |
|
166 IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
167 IMPORT_C void HexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen); |
|
168 IMPORT_C static void Write(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, const TDesC16& aText); |
|
169 IMPORT_C static void WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC16> aFmt,...); |
|
170 IMPORT_C static void WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC16> aFmt, VA_LIST& aList); |
|
171 IMPORT_C static void Write(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, const TDesC8& aText); |
|
172 IMPORT_C static void WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC8> aFmt,...); |
|
173 IMPORT_C static void WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
174 IMPORT_C static void HexDump(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen); |
|
175 IMPORT_C TInt LastError() const; |
|
176 IMPORT_C TBool LogValid() const; |
|
177 |
|
178 private: |
|
179 TInt DoConnect(); |
|
180 void DoWrite(const TDesC8& aBuf); |
|
181 void DoStaticWrite(const TDesC8& aBuf); |
|
182 void DoWriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList); |
|
183 void DoWriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
184 static void DoStaticWriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC16> aFmt, VA_LIST& aList); |
|
185 static void DoStaticWriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC8> aFmt, VA_LIST& aList); |
|
186 void DoHexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen); |
|
187 private: |
|
188 TLogFormatter iFormatter; |
|
189 TLogFile iLogFile; |
|
190 TInt iLastError; |
|
191 }; |
|
192 |
|
193 #endif |
|