1.1 --- a/epoc32/include/flogger.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,193 +0,0 @@
1.4 -// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 -// All rights reserved.
1.6 -// This component and the accompanying materials are made available
1.7 -// 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
1.8 -// which accompanies this distribution, and is available
1.9 -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 -//
1.11 -// Initial Contributors:
1.12 -// Nokia Corporation - initial contribution.
1.13 -//
1.14 -// Contributors:
1.15 -//
1.16 -// Description:
1.17 -// FLogger Client side header
1.18 -//
1.19 -//
1.20 -
1.21 -
1.22 -
1.23 -/**
1.24 - @file
1.25 - @internalTechnology
1.26 -*/
1.27 -
1.28 -
1.29 -
1.30 -#ifndef __FLOGGER_H__
1.31 -#define __FLOGGER_H__
1.32 -
1.33 -#include <e32base.h>
1.34 -
1.35 -/** Maximum log buffer size.
1.36 -@internalTechnology */
1.37 -const TInt KLogBufferSize=150;
1.38 -
1.39 -// [All of this start up stuff copied from DBMS]
1.40 -
1.41 -class FLogger
1.42 -/** Controls the flogger server.
1.43 -@internalComponent */
1.44 - {
1.45 -public:
1.46 - class TSignal
1.47 -/**
1.48 -@internalComponent
1.49 -*/
1.50 - {
1.51 - friend class FLogger;
1.52 - public:
1.53 - inline TSignal() {}
1.54 - inline TInt Set(const TDesC& aCommand);
1.55 -
1.56 - inline TSignal(TRequestStatus& aStatus);
1.57 -
1.58 - inline TPtrC Command() const;
1.59 -
1.60 - private:
1.61 - TRequestStatus* iStatus;
1.62 - TThreadId iId;
1.63 - };
1.64 -public:
1.65 - static TInt Start();
1.66 -
1.67 - IMPORT_C static TInt Run(TSignal& aSignal);
1.68 -
1.69 -private:
1.70 - static TInt Init();
1.71 - };
1.72 -
1.73 -
1.74 -/** The mode used to write to the log file.
1.75 -@internalTechnology */
1.76 -enum TFileLoggingMode
1.77 - {
1.78 - /** Log file mode has not been explicitly set. */
1.79 - EFileLoggingModeUnknown =0,
1.80 - /** Open the log file in append mode. */
1.81 - EFileLoggingModeAppend,
1.82 - /** Open the log file in overwrite mode. */
1.83 - EFileLoggingModeOverwrite,
1.84 - EFileLoggingModeAppendRaw,
1.85 - EFileLoggingModeOverwriteRaw
1.86 - };
1.87 -
1.88 -NONSHARABLE_CLASS(TLogFormatter16Overflow) :public TDes16Overflow
1.89 -/** Unicode overflow handler.
1.90 -@internalComponent */
1.91 - {
1.92 -public:
1.93 - virtual void Overflow(TDes16& aDes);
1.94 - };
1.95 -
1.96 -NONSHARABLE_CLASS(TLogFormatter8Overflow) :public TDes8Overflow
1.97 -/** Overflow handler.
1.98 -@internalComponent */
1.99 - {
1.100 -public:
1.101 - virtual void Overflow(TDes8& aDes);
1.102 - };
1.103 -
1.104 -class TLogFormatter
1.105 -/** Formatting methods for log file data.
1.106 -@internalComponent */
1.107 - {
1.108 -public:
1.109 - TLogFormatter();
1.110 - void SetDateAndTime(TBool aUseDate,TBool aUseTime);
1.111 - TInt FormatTextToWritableBuffer(TDes8& aBuf, const TDesC16& aText) const;
1.112 - TInt FormatTextToWritableBuffer(TDes8& aBuf, const TDesC8& aText) const;
1.113 - TInt ConvertToWritableBuffer(TDes8& aBuf, TRefByValue<const TDesC16> aFmt, VA_LIST& aList);
1.114 - TInt ConvertToWritableBuffer(TDes8& aBuf, TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
1.115 -private:
1.116 - void GetDateAndTimeL(TDes& aDate, TDes& aTime) const;
1.117 - void WriteL(TDes8& aTrg, const TDesC16& aSrc) const;
1.118 - void WriteL(TDes8& aTrg, const TDesC8& aSrc) const;
1.119 -private:
1.120 - TBool iUseDate;
1.121 - TBool iUseTime;
1.122 - TLogFormatter16Overflow iOverflow16;
1.123 - TLogFormatter8Overflow iOverflow8;
1.124 - };
1.125 -
1.126 -class TLogFile
1.127 -/** General access to packaged log files.
1.128 -@internalComponent */
1.129 - {
1.130 -public:
1.131 - TLogFile();
1.132 - TLogFile(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode);
1.133 - TBool operator==(const TLogFile& aLogFile) const;
1.134 - void Set(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode);
1.135 - inline TBool Valid() const;
1.136 - inline TFileName Directory() const;
1.137 - inline TFileName Name() const;
1.138 - inline TFileLoggingMode Mode() const;
1.139 - inline void SetValid(TBool aValid);
1.140 -private:
1.141 - TBool iValid;
1.142 - TFileName iDirectory;
1.143 - TFileName iName;
1.144 - TFileLoggingMode iMode;
1.145 - };
1.146 -
1.147 -#include <flogger.inl>
1.148 -
1.149 -class RFileLogger : public RSessionBase
1.150 -/** Provides access methods to file logging.
1.151 -
1.152 -The file logger API contains both static and non-static versions of access
1.153 -functions to the file logging system.
1.154 -@internalTechnology */
1.155 - {
1.156 -public:
1.157 - IMPORT_C RFileLogger();
1.158 - IMPORT_C ~RFileLogger();
1.159 - IMPORT_C TVersion Version() const;
1.160 - IMPORT_C TInt Connect();
1.161 - IMPORT_C void SetDateAndTime(TBool aUseDate,TBool aUseTime);
1.162 - IMPORT_C void CreateLog(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode);
1.163 - IMPORT_C void CloseLog();
1.164 - IMPORT_C void Write(const TDesC16& aText);
1.165 - IMPORT_C void WriteFormat(TRefByValue<const TDesC16> aFmt,...);
1.166 - IMPORT_C void WriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList);
1.167 - IMPORT_C void Write(const TDesC8& aText);
1.168 - IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt,...);
1.169 - IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
1.170 - IMPORT_C void HexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen);
1.171 - IMPORT_C static void Write(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, const TDesC16& aText);
1.172 - IMPORT_C static void WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC16> aFmt,...);
1.173 - IMPORT_C static void WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC16> aFmt, VA_LIST& aList);
1.174 - IMPORT_C static void Write(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, const TDesC8& aText);
1.175 - IMPORT_C static void WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC8> aFmt,...);
1.176 - IMPORT_C static void WriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
1.177 - IMPORT_C static void HexDump(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen);
1.178 - IMPORT_C TInt LastError() const;
1.179 - IMPORT_C TBool LogValid() const;
1.180 -
1.181 -private:
1.182 - TInt DoConnect();
1.183 - void DoWrite(const TDesC8& aBuf);
1.184 - void DoStaticWrite(const TDesC8& aBuf);
1.185 - void DoWriteFormat(TRefByValue<const TDesC16> aFmt, VA_LIST& aList);
1.186 - void DoWriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
1.187 - static void DoStaticWriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC16> aFmt, VA_LIST& aList);
1.188 - static void DoStaticWriteFormat(const TDesC& aDir, const TDesC& aName, TFileLoggingMode aMode, TRefByValue<const TDesC8> aFmt, VA_LIST& aList);
1.189 - void DoHexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen);
1.190 -private:
1.191 - TLogFormatter iFormatter;
1.192 - TLogFile iLogFile;
1.193 - TInt iLastError;
1.194 - };
1.195 -
1.196 -#endif