btservices_plat/obex_service_utils_api/tsrc/inc/testlogger.h
branchRCL_3
changeset 56 9386f31cc85b
parent 55 613943a21004
child 61 269724087bed
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef BTTESTLOGGER_H
       
    20 #define BTTESTLOGGER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CStifLogger;
       
    27 class CTestModuleIf;
       
    28 
       
    29 #define TLFUNCLOG (TUint8*) __FUNCTION__
       
    30 
       
    31 // CLASS DECLARATION
       
    32 
       
    33 NONSHARABLE_CLASS( CObexTestLogger ) : public CBase
       
    34 {
       
    35 	public:
       
    36 	
       
    37 		static CObexTestLogger* NewL(const CTestModuleIf* aTestModuleIf);
       
    38 		virtual ~CObexTestLogger();
       
    39 
       
    40 	public: // Data used by functions
       
    41 
       
    42 		enum TLogLevel {ETLError, ETLResult, ETLInfo, ETLDebug};
       
    43 
       
    44 	public: // New functions
       
    45 	
       
    46 		TBool GetEnabled() const;
       
    47 		CStifLogger* GetLogger() const;
       
    48 		const CTestModuleIf* GetTestModuleIf() const;
       
    49 		TInt Log(TLogLevel aLevel, TRefByValue<const TDesC8> aLogText, ...) const;
       
    50 		TInt Log(const TDesC& aCategory, TRefByValue<const TDesC8> aLogText, ...) const;
       
    51 		TInt Log(TLogLevel aLevel, TRefByValue<const TDesC16> aLogText, ...) const;
       
    52 		TInt Log(const TDesC& aCategory, TRefByValue<const TDesC16> aLogText, ...) const;
       
    53 		TInt LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const;
       
    54 		TInt LogNewLine() const;
       
    55 		void SetEnabled(TBool aEnabled);
       
    56 		void SetLogger(CStifLogger* aLog);
       
    57 		void SetTestModuleIf(const CTestModuleIf* aTestModuleIf);
       
    58 
       
    59 	public: // Functions from base classes
       
    60 
       
    61 	private:  // New functions
       
    62 
       
    63 		TInt WriteLog(TLogLevel aLevel, TDes16& aLog) const;
       
    64 		TInt WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const;
       
    65 		static TPtrC GetPrefix(TLogLevel aLevel);
       
    66 		TInt CheckLogFile();
       
    67 		void LogHeadSectionL();
       
    68 		void LogTimeStampL(TDes& aBuf, TBool aTime = ETrue) const;
       
    69 
       
    70 	private:  // Constructors
       
    71 	
       
    72 		CObexTestLogger(const CTestModuleIf* aTestModuleIf);
       
    73 		void ConstructL();
       
    74 
       
    75 	public:     // Data
       
    76 		static const TInt KPrefixLength;
       
    77 
       
    78 	private:    // Data
       
    79 
       
    80 		TBool iEnabled;
       
    81 		CStifLogger* iLog;
       
    82 		const CTestModuleIf* iTestModuleIf;
       
    83 	};
       
    84 
       
    85 #endif // BTTESTLOGGER_H
       
    86