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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // FLogger Client side header
32 /** Maximum log buffer size.
33 @internalTechnology */
34 const TInt KLogBufferSize=150;
36 // [All of this start up stuff copied from DBMS]
39 /** Controls the flogger server.
51 inline TInt Set(const TDesC& aCommand);
53 inline TSignal(TRequestStatus& aStatus);
55 inline TPtrC Command() const;
58 TRequestStatus* iStatus;
64 IMPORT_C static TInt Run(TSignal& aSignal);
71 /** The mode used to write to the log file.
72 @internalTechnology */
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
85 NONSHARABLE_CLASS(TLogFormatter16Overflow) :public TDes16Overflow
86 /** Unicode overflow handler.
90 virtual void Overflow(TDes16& aDes);
93 NONSHARABLE_CLASS(TLogFormatter8Overflow) :public TDes8Overflow
98 virtual void Overflow(TDes8& aDes);
102 /** Formatting methods for log file data.
103 @internalComponent */
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);
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;
119 TLogFormatter16Overflow iOverflow16;
120 TLogFormatter8Overflow iOverflow8;
124 /** General access to packaged log files.
125 @internalComponent */
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);
139 TFileName iDirectory;
141 TFileLoggingMode iMode;
144 #include <flogger.inl>
146 class RFileLogger : public RSessionBase
147 /** Provides access methods to file logging.
149 The file logger API contains both static and non-static versions of access
150 functions to the file logging system.
151 @internalTechnology */
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;
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);
188 TLogFormatter iFormatter;