epoc32/include/test/testexecutelog.h
branchSymbian3
changeset 4 837f303aceeb
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file TestExecuteLog.h
       
    21 */
       
    22 
       
    23 #if !(defined __TESTEXECUTE_LOG_H__)
       
    24 #define __TESTEXECUTE_LOG_H__
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <test/tefexportconst.h>
       
    28 
       
    29 _LIT8(KTEFOverflowMessage8, "\t..Message Truncated");
       
    30 _LIT16(KTEFOverflowMessage16, "\t..Message Truncated");
       
    31 const TInt overflowMessageLen = 21; // Size of the truncation message. To be changed if the text above is changed
       
    32 
       
    33 /**
       
    34  @internalComponent
       
    35  @test
       
    36  * Derived class implementation of TDes16Overflow class
       
    37  * Implements the base class pure virtual Overflow() to handle descriptor overflow
       
    38  * during AppendFormatList() operations on TDes16 objects
       
    39  */
       
    40 class TTEFDes16Overflow : public TDes16Overflow
       
    41 	{
       
    42 	inline virtual void Overflow(TDes16& aDes)
       
    43 		{
       
    44 		TInt actualMessageLen = aDes.Length();
       
    45 		TInt maxLengthOfDes = aDes.MaxLength();
       
    46 
       
    47 		TInt midPosForEdit = maxLengthOfDes - overflowMessageLen;
       
    48 		if (actualMessageLen <= midPosForEdit)
       
    49 			{
       
    50 			aDes.Append(KTEFOverflowMessage16());
       
    51 			}
       
    52 		else
       
    53 			{
       
    54 			aDes.SetLength(midPosForEdit + overflowMessageLen);
       
    55 			aDes.Replace(midPosForEdit, overflowMessageLen, KTEFOverflowMessage16());
       
    56 			}
       
    57 		}
       
    58 	};
       
    59 
       
    60 /**
       
    61  @internalComponent
       
    62  @test
       
    63  * Derived class implementation of TDes8Overflow class
       
    64  * Implements the base class pure virtual Overflow() to handle descriptor overflow
       
    65  * during AppendFormatList() operations on TDes8 objects
       
    66  */
       
    67 class TTEFDes8Overflow : public TDes8Overflow
       
    68 	{
       
    69 	inline virtual void Overflow(TDes8& aDes)
       
    70 		{
       
    71 		TInt actualMessageLen = aDes.Length();
       
    72 		TInt maxLengthOfDes = aDes.MaxLength();
       
    73 
       
    74 		TInt midPosForEdit = maxLengthOfDes - overflowMessageLen;
       
    75 		if (actualMessageLen <= midPosForEdit)
       
    76 			{
       
    77 			aDes.Append(KTEFOverflowMessage8());
       
    78 			}
       
    79 		else
       
    80 			{
       
    81 			aDes.SetLength(midPosForEdit + overflowMessageLen);
       
    82 			aDes.Replace(midPosForEdit, overflowMessageLen, KTEFOverflowMessage8());
       
    83 			}
       
    84 		}
       
    85 	};
       
    86 
       
    87 class RTestExecuteLogServ : public RSessionBase
       
    88 /**
       
    89 @internalComponent
       
    90 @test
       
    91 */
       
    92 	{
       
    93 public:
       
    94 	enum TLogMode{ELogModeAppend,ELogModeOverWrite};
       
    95 	// Logging level
       
    96 	enum TLogCommand{ECreateLog,EWriteLog};
       
    97 
       
    98 	IMPORT_C TInt Connect();
       
    99 	IMPORT_C TInt CreateLog(const TDesC& aLogFilePath,TLogMode aMode);
       
   100 	IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt,...);
       
   101 	IMPORT_C void Write(const TDesC& aLogBuffer);
       
   102 	IMPORT_C void WriteFormat(TRefByValue<const TDesC> aFmt,...);
       
   103 	IMPORT_C void Write(const TDesC8& aLogBuffer);
       
   104 	IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt,...);
       
   105 	IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt, VA_LIST aList);
       
   106 	IMPORT_C void WriteFormat(TRefByValue<const TDesC> aFmt, VA_LIST aList);
       
   107 	IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST aList);
       
   108 	IMPORT_C void SetLogLevel(TLogSeverity aSeverity);
       
   109 private:
       
   110 	void WriteL(const TDesC& aLogBuffer);
       
   111 	void WriteL(TDes8& aLogBuffer);
       
   112 	void GetCPPModuleName(TDes& aModuleName, const TText8* aCPPFileName);
       
   113 	void AddTime(TDes8& aTime);
       
   114 	TLogSeverity iLogLevel;
       
   115 	};
       
   116 #endif