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