os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/inc/DataLogger.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Test_Bed/inc/DataLogger.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,287 @@
     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 "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.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 +// This file contains the definition of the class CDataLogger
    1.18 +// This file comment is for DOxygen only and is ignored by EDoc.
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @test
    1.24 +*/
    1.25 +
    1.26 +#ifndef __DATALOGGER_H__
    1.27 +#define __DATALOGGER_H__
    1.28 +
    1.29 +#include <e32base.h>
    1.30 +#include <flogger.h>
    1.31 +#include <ecom/test_bed/dataformat.h>
    1.32 +#include <ecom/test_bed/defaultlogoutput.h>
    1.33 +
    1.34 +/**
    1.35 +	@internalAll
    1.36 +	Comments : Handles the transformation of input data into text suitable 
    1.37 +		for output to a permanent store and the placing of that 
    1.38 +		data in the store.
    1.39 + */
    1.40 +
    1.41 +
    1.42 +class CDataLogger : public CBase
    1.43 +	{
    1.44 +public:
    1.45 +/**
    1.46 +	@fn				static CDataLogger* NewL(TLoggingInfo* aLogInfo)
    1.47 +	Intended Usage	: Standardized safe construction which leaves nothing on the cleanup stack.
    1.48 +	@leave  		KErrNoMemory.	
    1.49 +	@since			7.0
    1.50 +	@param			aLogInfo The logging configuration information
    1.51 +	@return			CDataLogger* A pointer to the newly created class.
    1.52 +	@pre 			None
    1.53 +	@post			Nothing is left on the CleanupStack
    1.54 + */
    1.55 +	
    1.56 +	static CDataLogger* NewL(TLoggingInfo* aLogInfo);
    1.57 +
    1.58 +/**
    1.59 +	@fn				static CDataLogger* NewLC(TLoggingInfo* aLogInfo)
    1.60 +	Intended Usage	: Standardized safe construction which leaves CDataLogger* on the cleanup stack.
    1.61 +	@leave  		KErrNoMemory.	
    1.62 +	@since			7.0
    1.63 +	@param			aLogInfo The logging configuration information
    1.64 +	@return			CDataLogger* A pointer to the newly created class.
    1.65 +	@pre 			None
    1.66 +	@post			CDataLogger is on the CleanupStack
    1.67 + */
    1.68 +	
    1.69 +	static CDataLogger* NewLC(TLoggingInfo* aLogInfo);
    1.70 +
    1.71 +/**
    1.72 +	@fn				 ~CDataLogger()
    1.73 +	Intended Usage	: Standardized virtual destruction method 
    1.74 +	@since			7.0
    1.75 + */
    1.76 +	
    1.77 +	~CDataLogger();
    1.78 +
    1.79 +/**
    1.80 +	@fn				IMPORT_C void DumpMemoryBlock(const TUint8* aAddress, TInt aLength)
    1.81 +	Intended Usage	:	Logs a block of memory to file in hexadecimal and ASCII format.
    1.82 +					For example:
    1.83 +					
    1.84 +	@code
    1.85 +	0000 : 40 fd 8f 01 38 fd 8f 01 21 5f 00 10 61 00 74 00 : @...8...!_..a.t.
    1.86 +	0010 : 61 55 ff 00 48 fd 8f 01 ac fd 8f 01 ac fd 8f 01 : aU..H...........
    1.87 +	0020 : 21 88 00 60 90 41 ff 00 01 00 00 00 24 1f 7b 00 : !..`.A......$.{.
    1.88 +	0030 : 61 00 74 00 72 00 65 00 34 fd 8f 01 23 00 f1 77 : a.t.r.e.4...#..w
    1.89 +	0040 : 23 00 00 00 38 00                               : #...8.          
    1.90 +	@endcode
    1.91 +
    1.92 +	@since			7.0
    1.93 +	@param			aAddress The address of the start of the block to be logged
    1.94 +	@param			aLength The number of bytes to be logged
    1.95 +	@pre 			None
    1.96 +	@post			The specified block of memory is output to file in hex and ASCII format
    1.97 + */
    1.98 +	
    1.99 +	IMPORT_C void DumpMemoryBlock(const TUint8* aAddress, TInt aLength);
   1.100 +
   1.101 +/**
   1.102 +	@fn				IMPORT_C void LogInformation(const TDesC16& aComment)
   1.103 +	Intended Usage	:	Add the specified comment to the log file. Wide descriptor version
   1.104 +	Error Condition	:	
   1.105 +	@since			7.0
   1.106 +	@param			aComment The text to be logged
   1.107 +	@pre 			None
   1.108 +	@post			The specified text is added to the log file
   1.109 + */
   1.110 +	
   1.111 +	IMPORT_C void LogInformation(const TDesC16& aComment);
   1.112 +
   1.113 +/**
   1.114 +	@fn				IMPORT_C void LogInformation(const TDesC8& aComment)
   1.115 +	Intended Usage	:	Add the specified comment to the log file. Narrow descriptor 
   1.116 +	version
   1.117 +	Error Condition	:	
   1.118 +	@since			7.0
   1.119 +	@param			aComment The text to be logged
   1.120 +	@pre 			None
   1.121 +	@post			The specified text is added to the log file
   1.122 + */
   1.123 +	
   1.124 +	IMPORT_C void LogInformation(const TDesC8& aComment);
   1.125 +
   1.126 +/**
   1.127 +	@fn				IMPORT_C void LogInformationWithParameters(TRefByValue<const TDesC16> aFormat, ...)
   1.128 +	Intended Usage	:	Add the specified comment to the log file. Wide descriptor version
   1.129 +	Error Condition	:	
   1.130 +	@since			7.0
   1.131 +	@param			aFormat The text to be formatted and logged
   1.132 +	@param			...	An argument set
   1.133 +	@pre 			None
   1.134 +	@post			The specified text is formatted and added to the log file
   1.135 + */
   1.136 +	
   1.137 +	IMPORT_C void LogInformationWithParameters(TRefByValue<const TDesC16> aFormat, ...);
   1.138 +
   1.139 +/**
   1.140 +	@fn				IMPORT_C void LogInformationWithParameters(TRefByValue<const TDesC8> aFormat, ...)
   1.141 +	Intended Usage	:	Add the specified comment to the log file. Narrow 
   1.142 +					descriptor version
   1.143 +	Error Condition	:	
   1.144 +	@since			7.0
   1.145 +	@param			aFormat The text to be formatted and logged
   1.146 +	@param			...	An argument set
   1.147 +	@pre 			None
   1.148 +	@post			The specified text is formatted and added to the log file
   1.149 + */
   1.150 +	
   1.151 +	IMPORT_C void LogInformationWithParameters(TRefByValue<const TDesC8> aFormat, ...);
   1.152 +
   1.153 +/**
   1.154 +	@fn				IMPORT_C void ReportInformation(const TDesC& aComment)
   1.155 +	Intended Usage	:	Add the specified comment to the report file
   1.156 +	Error Condition	:	
   1.157 +	@since			7.0
   1.158 +	@param			aComment The text to be logged
   1.159 +	@pre 			None
   1.160 +	@post			The specified text is added to the report file
   1.161 + */
   1.162 +	
   1.163 +	IMPORT_C void ReportInformation(const TDesC& aComment);
   1.164 +
   1.165 +/**
   1.166 +	@fn				IMPORT_C void ReportInformationWithParameters(TRefByValue<const TDesC> aFormat, ...)
   1.167 +	Intended Usage	:	Add the specified comment to the report file
   1.168 +	Error Condition	:	
   1.169 +	@since			7.0
   1.170 +	@param			aFormat The text to be formatted and logged
   1.171 +	@param			...	An argument set
   1.172 +	@pre 			None
   1.173 +	@post			The specified text is formatted and added to the log file
   1.174 + */
   1.175 +	
   1.176 +	IMPORT_C void ReportInformationWithParameters(TRefByValue<const TDesC> aFormat, ...);
   1.177 +
   1.178 +private:
   1.179 +/**
   1.180 +	@fn				CDataLogger()
   1.181 +	Intended Usage	: Constructor
   1.182 +	@since			7.0
   1.183 + */
   1.184 +	
   1.185 +	CDataLogger();
   1.186 +
   1.187 +/**
   1.188 +	@fn				void ConstructL(TLoggingInfo* aLogInfo)
   1.189 +	Intended Usage	: Completes the safe construction of the CDataLogger object
   1.190 +	@leave  		KErrNoMemory.
   1.191 +	@since			7.0
   1.192 +	@param			aLogInfo The logging configuration information
   1.193 +	@pre 			First phase of construction is complete
   1.194 +	@post			CDatalogger is fully constructed
   1.195 + */
   1.196 +	
   1.197 +	void ConstructL(TLoggingInfo* aLogInfo);
   1.198 +
   1.199 +/**
   1.200 +	@fn				void SetupRDebugL(TBool aRequest)
   1.201 +	Intended Usage	:	
   1.202 +	Error Condition	:	
   1.203 +	@since			7.0
   1.204 +	@param			TBool aRequest " "
   1.205 +	@pre 			Called only from ConstructL()
   1.206 +	@post			iDebug is set up for debug outputting or not.
   1.207 + */
   1.208 +	
   1.209 +	void SetupRDebugL(TBool aRequest);
   1.210 +
   1.211 +/**
   1.212 +	@fn				void Log(MLogOutput* aLogOutput, const TDesC16& aMessage)
   1.213 +	Intended Usage	:	Helper function which will log out a descriptor.  The destination for
   1.214 +	logging depends whether an alternative logger was supplied by the user at construction.
   1.215 +	Descriptors to be logged are broken up into maximum lengths of 150 as this is more 
   1.216 +	manageable and is the limit supported by RFileLogger.  Wide descriptor version.
   1.217 +	@since			7.0
   1.218 +	@param			aLogOutput The logging mechanism to use
   1.219 +	@param			aMessage The descriptor to log
   1.220 +	@pre 			This CDataLogger is constructed
   1.221 +	@post			The message is logged to the destination
   1.222 + */
   1.223 +	
   1.224 +	void Log(MLogOutput* aLogOutput, const TDesC16& aMessage);
   1.225 +
   1.226 +/**
   1.227 +	@fn				void SetupLoggingL(TLoggingInfo* aLogInfo)
   1.228 +	Intended Usage	:
   1.229 +	Error Condition	:
   1.230 +	@since			7.0
   1.231 +	@param			aLogInfo The user supplied logging configuration information
   1.232 +	@pre 			Called from ConstructL()
   1.233 +	@post			Logging output objects are configured.
   1.234 + */
   1.235 +	
   1.236 +	void SetupLoggingL(TLoggingInfo* aLogInfo);
   1.237 +
   1.238 +private:
   1.239 +/** A do nothing base class for debug logging */
   1.240 +	class TNullDebugPrint
   1.241 +		{
   1.242 +		public:
   1.243 +			virtual void Print(const TDesC&);
   1.244 +		};
   1.245 +
   1.246 +/** An override class for debug logging to RDebug */
   1.247 +	NONSHARABLE_CLASS(TDebugPrint) : public TNullDebugPrint
   1.248 +		{
   1.249 +		public:
   1.250 +			/** Print the output to RDebug */
   1.251 +			void Print(const TDesC& aMessage);
   1.252 +		};
   1.253 +/** The class instance */
   1.254 +	
   1.255 +	TNullDebugPrint* iDebug;
   1.256 +
   1.257 +/** The logging style to be used (plain text, HTML or custom). */
   1.258 +	
   1.259 +	TLoggingStyle	iLogStyle;
   1.260 +/** The logging formats to be used if iLogStyle is HTML or custom. */
   1.261 +	
   1.262 +	TLogFormat		iLogFormat;
   1.263 +/** Provides the file logging facilities*/
   1.264 +	
   1.265 +	MLogOutput*		iLogOutput;
   1.266 +/** Provides the reporting facilities*/
   1.267 +	
   1.268 +	MLogOutput*		iReportOutput;
   1.269 +/** Pointer to a default log output if the user doesn't supply one */
   1.270 +	
   1.271 +	CDefaultLogOutput*	iDefaultLogOutput;
   1.272 +/** Pointer to a default report output if the user doesn't supply one */
   1.273 +	
   1.274 +	CDefaultLogOutput*	iDefaultReportOutput;
   1.275 +/** Provides the file reporting facilities*/
   1.276 +	
   1.277 +	RFileLogger		iReportFlogger;
   1.278 +/** Provides the area for formatting log and report data */
   1.279 +	
   1.280 +	HBufC*			iFormatBuf;
   1.281 +/** Make the test State Accessor a friend */
   1.282 +	friend class TDataLogger_StateAccessor;
   1.283 +	};
   1.284 +
   1.285 +inline void CDataLogger::TNullDebugPrint::Print(const TDesC&)
   1.286 +	{
   1.287 +	// Do nothing
   1.288 +	}
   1.289 +
   1.290 +#endif