testexecfw/stf/stfext/testmodules/teftestmod/testexecmdw/filelogger/inc/rfilelogger.h
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     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 "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 
       
    20 /**
       
    21  @file RFileLogger.h
       
    22 */
       
    23 
       
    24 #if !(defined __ET_RFILELOGGER_H__)
       
    25 #define __ET_RFILELOGGER_H__
       
    26 
       
    27 #include <e32base.h>
       
    28 
       
    29 const TInt KMaxSizOfTag=128;
       
    30 const TInt KMaxSizOfString = 256;
       
    31 const TInt KMaxFilename = 50;
       
    32 
       
    33 // *** Maintaince warning: the constant designed
       
    34 // used on both server side and client side. Any change shoud be
       
    35 // checked on both side
       
    36 _LIT(KMessageFormat," - %d - %S - %d - ");
       
    37 
       
    38 _LIT(KSeperation," - ");
       
    39 _LIT8(KSeperation8," - ");
       
    40 _LIT(KTagSeperation,"LogFieldsRequiredBeingAddedToAboveLogMessage");
       
    41 _LIT(KTagSeperationEnd,"\t\t\t\t\t\t"); // make them invisible
       
    42 _LIT(KTagSeperation8,"LogFieldsRequiredBeingAddedToAboveLogMessage");
       
    43 _LIT(KTagSeperationEnd8,"\t\t\t\t\t\t"); // make them invisible
       
    44 // *** End of Maintaince warning
       
    45 
       
    46 
       
    47 //#if !(defined __FILELOGGER_UREL)
       
    48 _LIT(KFileLogrerServerName,"RFileLoggerServer");
       
    49 const TInt KMaxLoggerFilePath = 256;
       
    50 const TInt KMaxLoggerLineLength = 512;
       
    51 
       
    52 const TInt KRFileLoggerMajorVersion = 1;
       
    53 const TInt KRFileLoggerMinorVersion = 1;
       
    54 const TInt KRFileLoggerBuildVersion = 1;
       
    55 
       
    56 struct TExtraLogField
       
    57 	{
       
    58 	TBuf<KMaxSizOfTag> iLogFieldName;
       
    59 	TBuf<KMaxSizOfString> iLogFieldValue;
       
    60 	};
       
    61 /**
       
    62  * RFileLoggerBody - class to provide internal data for the client side
       
    63  *
       
    64  * This class contains all data members which would otherwise be in the
       
    65  * RFileLogger class. They are instead in this file since that because
       
    66  * CreateSession is a protected member of RSessionBase, so we must derive
       
    67  *from it and provide a means to call this via pass-through inline functions.
       
    68  */
       
    69 class RFileLoggerBody : public RSessionBase
       
    70 {
       
    71 public:
       
    72 	inline TInt DoCreateSession(const TDesC& aServer,const TVersion& aVersion,TInt aAsyncMessageSlots);
       
    73 	inline TInt DoSendReceive(TInt aFunction,const TIpcArgs& aArgs) const;
       
    74 	inline TInt DoSendReceive(TInt aFunction) const;
       
    75 
       
    76 	
       
    77 };
       
    78 
       
    79 inline TInt RFileLoggerBody::DoCreateSession(const TDesC& aServer,const TVersion& aVersion,TInt aAsyncMessageSlots)
       
    80 	{
       
    81 	return CreateSession(aServer,aVersion,aAsyncMessageSlots);
       
    82 	}
       
    83 
       
    84 inline TInt RFileLoggerBody::DoSendReceive(TInt aFunction,const TIpcArgs& aArgs) const
       
    85 	{
       
    86 	return SendReceive(aFunction,aArgs);
       
    87 	}
       
    88 
       
    89 inline TInt RFileLoggerBody::DoSendReceive(TInt aFunction) const
       
    90 	{
       
    91 	return SendReceive(aFunction);
       
    92 	}
       
    93 
       
    94 class RFileFlogger
       
    95 /**
       
    96 @internalComponent
       
    97 @test
       
    98 */
       
    99 	{
       
   100 public:
       
   101 	enum TLogMode{ELogModeAppend,ELogModeOverWrite};
       
   102 	// Logging level
       
   103 	enum TLogSeverity{ESevrErr  = 1,ESevrHigh, ESevrWarn, ESevrMedium, ESevrInfo, ESevrLow, ESevrTEFUnit, ESevrAll};
       
   104 	enum TLogCommand{ECreateLog,EWriteLog};
       
   105 
       
   106 	enum TLogType{EXml,ETxt};
       
   107 	
       
   108 	IMPORT_C RFileFlogger();
       
   109 	IMPORT_C ~RFileFlogger();
       
   110 	
       
   111 
       
   112 	IMPORT_C TInt Connect(); 
       
   113 	IMPORT_C TInt CreateLog(const TDesC& aLogFilePath,TLogMode aMode);
       
   114 	IMPORT_C void Log(const TText8* aFile, TInt aLine, TLogSeverity aSeverity, TRefByValue<const TDesC> aFmt,...);
       
   115 	IMPORT_C void Log(const TText8* aFile, TInt aLine, TLogSeverity aSeverity, TInt arraylength, TExtraLogField* aLogFields, TRefByValue<const TDesC> aFmt,...);
       
   116 
       
   117 	IMPORT_C void SetLogLevel(TLogSeverity aloglevel); 
       
   118 	IMPORT_C void Close();
       
   119 	IMPORT_C void Log(const TText8* aFile, TInt aLine, TLogSeverity aSeverity,TRefByValue<const TDesC> aFmt, VA_LIST aList);
       
   120 	IMPORT_C void Log(const TText8* aFile, TInt aLine, TLogSeverity aSeverity, TInt arraylength, TExtraLogField* aLogFields, TRefByValue<const TDesC> aFmt, VA_LIST aList);	
       
   121 
       
   122 private:
       
   123 	void GetCPPModuleName(TDes& aModuleName, const TText8* aCPPFileName);
       
   124 	void WriteL(const TDesC& aLogBuffer);
       
   125 	void WriteL(TDes8& aLogBuffer);
       
   126 	void AddTime(TDes8& aTime);
       
   127 
       
   128 	RFileLoggerBody* ilogbody;
       
   129 
       
   130 	TLogSeverity iloglevel;
       
   131 	TBool iLogfileTag;
       
   132 
       
   133 
       
   134 	};
       
   135 
       
   136 
       
   137 #endif