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