shortlinkconn_plat/obex_service_utils_api/tsrc/inc/testlogger.h
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:20:40 +0100
branchRCL_3
changeset 40 52a167391590
parent 11 87d139e87731
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035

/*
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/


#ifndef BTTESTLOGGER_H
#define BTTESTLOGGER_H

// INCLUDES
#include <e32base.h>

// FORWARD DECLARATIONS
class CStifLogger;
class CTestModuleIf;

#define TLFUNCLOG (TUint8*) __FUNCTION__

// CLASS DECLARATION

NONSHARABLE_CLASS( CObexTestLogger ) : public CBase
{
	public:
	
		static CObexTestLogger* NewL(const CTestModuleIf* aTestModuleIf);
		virtual ~CObexTestLogger();

	public: // Data used by functions

		enum TLogLevel {ETLError, ETLResult, ETLInfo, ETLDebug};

	public: // New functions
	
		TBool GetEnabled() const;
		CStifLogger* GetLogger() const;
		const CTestModuleIf* GetTestModuleIf() const;
		TInt Log(TLogLevel aLevel, TRefByValue<const TDesC8> aLogText, ...) const;
		TInt Log(const TDesC& aCategory, TRefByValue<const TDesC8> aLogText, ...) const;
		TInt Log(TLogLevel aLevel, TRefByValue<const TDesC16> aLogText, ...) const;
		TInt Log(const TDesC& aCategory, TRefByValue<const TDesC16> aLogText, ...) const;
		TInt LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const;
		TInt LogNewLine() const;
		void SetEnabled(TBool aEnabled);
		void SetLogger(CStifLogger* aLog);
		void SetTestModuleIf(const CTestModuleIf* aTestModuleIf);

	public: // Functions from base classes

	private:  // New functions

		TInt WriteLog(TLogLevel aLevel, TDes16& aLog) const;
		TInt WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const;
		static TPtrC GetPrefix(TLogLevel aLevel);
		TInt CheckLogFile();
		void LogHeadSectionL();
		void LogTimeStampL(TDes& aBuf, TBool aTime = ETrue) const;

	private:  // Constructors
	
		CObexTestLogger(const CTestModuleIf* aTestModuleIf);
		void ConstructL();

	public:     // Data
		static const TInt KPrefixLength;

	private:    // Data

		TBool iEnabled;
		CStifLogger* iLog;
		const CTestModuleIf* iTestModuleIf;
	};

#endif // BTTESTLOGGER_H