testexecfw/stf/api/api_platform/inc/STFLogger.h
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     1 /*
       
     2 * Copyright (c) 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 // This file defines the API for STFLogger.dll
       
    20 
       
    21 #ifndef __STFLOGGER_H__
       
    22 #define __STFLOGGER_H__
       
    23 
       
    24 //  Include Files
       
    25 
       
    26 #include <e32base.h>	// CBase
       
    27 #include <e32std.h>	 // TBuf
       
    28 #include <f32file.h>
       
    29 #include <stiflogger.h>
       
    30 
       
    31 
       
    32 #define __DECLARE_LOG               RSTFLogger stf_Logger;
       
    33 #define __OPENLOGL(D, L)            User::LeaveIfError(stf_Logger.Connect()); \
       
    34                                     TParse p; \
       
    35                                     _LIT(KLogFile, L); \
       
    36                                     p.Set(KLogFile(), NULL, NULL); \
       
    37                                     _LIT(KLogDir, D); \
       
    38                                     stf_Logger.CreateL(KLogDir(), p.NameAndExt());
       
    39 #define __CLOSELOG                  stf_Logger.Close();
       
    40 extern RSTFLogger stf_Logger;
       
    41 
       
    42 //These type of log should be used as: __LOG(_L("test"));
       
    43 #define __LOG(C)                    stf_Logger.Log(C);
       
    44 #define __LOG1(C, Z)                stf_Logger.Log(C, Z);
       
    45 #define __LOG2(C, Z, Y)             stf_Logger.Log(C, Z, Y);
       
    46 #define __LOG3(C, Z, Y, X)          stf_Logger.Log(C, Z, Y, X);
       
    47 #define __LOG4(C, Z, Y, X, W)       stf_Logger.Log(C, Z, Y, X, W);
       
    48 #define __LOG5(C, Z, Y, X, W, V)    stf_Logger.Log(C, Z, Y, X, W, V);
       
    49 #define __LOG6(C, Z, Y, X, W, V, U) stf_Logger.Log(C, Z, Y, X, W, V, U);
       
    50 
       
    51 
       
    52 
       
    53 
       
    54 class RSTFLogger : public RSessionBase
       
    55 	{
       
    56 public:
       
    57     
       
    58 	// new functions
       
    59 	IMPORT_C TInt Connect();
       
    60 
       
    61 public: // new functions, example API
       
    62 		
       
    63 	IMPORT_C TInt CreateL(	const TDesC& aTestPath,
       
    64 				            const TDesC& aTestFile,
       
    65 				            // Default logger type is .txt
       
    66 				            CStifLogger::TLoggerType aLoggerType = CStifLogger::ETxt,
       
    67 				            // By default output is file
       
    68 				            CStifLogger::TOutput aOutput = CStifLogger::EFile,
       
    69 				            // By default overwrite is used
       
    70 				            TBool aOverWrite = ETrue,
       
    71 				            // By default time stamp is used
       
    72 				            TBool aWithTimeStamp = ETrue,
       
    73 				            // By default line break is used
       
    74 				            TBool aWithLineBreak = ETrue,
       
    75 				            // By default even ranking is not
       
    76 				            // used
       
    77 				            TBool aWithEventRanking = EFalse,
       
    78 				            // By default thread id is added
       
    79 				            // after the log file
       
    80 				            TBool aThreadIdToLogFile = ETrue,
       
    81 				            // By default log directory will
       
    82 				            // not create
       
    83 				            TBool aCreateLogDir = EFalse,
       
    84 				            // Static logger implementation is
       
    85 				            // not yet permanent, may change 
       
    86 				            TInt aStaticBufferSize = 0,
       
    87 				            // By default files are not written
       
    88 				            // in unicode format
       
    89 				            TBool aUnicode = EFalse );
       
    90 	
       
    91 	   IMPORT_C TInt CreateL(   const TDesC& aTestPath,
       
    92 	                           const TDesC& aTestFile,
       
    93                                TLoggerSettings& aLoggerSettings );
       
    94 	
       
    95     /**
       
    96     * Log a 16 bit information to some storage e.g. text file.
       
    97     */
       
    98     IMPORT_C TInt Log( const TDesC& aLogInfo );
       
    99 
       
   100     /**
       
   101     * Log a 8 bit information to some storage e.g. text file.
       
   102     */
       
   103     IMPORT_C TInt Log( const TDesC8& aLogInfo );
       
   104 
       
   105     /**
       
   106     * Log a 16 bit information to some storage e.g. text file. There is
       
   107     * also parameter to styling text information e.g. text color.
       
   108     */
       
   109     IMPORT_C TInt Log( TInt aStyle, const TDesC& aLogInfo );
       
   110 
       
   111     /**
       
   112     * Log a 8 bit information to some storage e.g. text file. There is
       
   113     * also parameter to styling text information e.g. text color.
       
   114     */
       
   115     IMPORT_C TInt Log( TInt aStyle, const TDesC8& aLogInfo );
       
   116 
       
   117     /**
       
   118     * Log a 16 bit information to some storage e.g. text file. In this log
       
   119     * method may set several parameters.
       
   120     */
       
   121     IMPORT_C TInt Log( TRefByValue<const TDesC> aLogInfo,... );
       
   122 
       
   123     /**
       
   124     * Log a 8 bit information to some storage e.g. text file. In this log
       
   125     * method may set several parameters.
       
   126     */
       
   127     IMPORT_C TInt Log( TRefByValue<const TDesC8> aLogInfo,... );
       
   128 
       
   129     /**
       
   130     * Log a 16 bit information to some storage e.g. text file. There is
       
   131     * also parameter to styling text information e.g. text color.
       
   132     */
       
   133     IMPORT_C TInt Log( TInt aStyle,
       
   134         TRefByValue<const TDesC> aLogInfo,... );
       
   135 
       
   136     /**
       
   137     * Log a 8 bit information to some storage e.g. text file. There is
       
   138     * also parameter to styling text information e.g. text color.
       
   139     */
       
   140     IMPORT_C TInt Log( TInt aStyle,
       
   141         TRefByValue<const TDesC8> aLogInfo,... );
       
   142 
       
   143     /**
       
   144     * Log a 16 bit delimiter. Default char is '#' and default
       
   145     * repeat count is 60.
       
   146     * This will be used if parameters are not given when calling
       
   147     * this method.
       
   148     */
       
   149     IMPORT_C TInt WriteDelimiter( const TDesC& aDelimiter = _L( "#"),
       
   150                                     TInt aCount = 60 );
       
   151 
       
   152     /**
       
   153     * Log a 8 bit delimiter. 8 bit delimiter includes no default values.
       
   154     * Delimiter may be '#' or 'XO' etc.
       
   155     */
       
   156     IMPORT_C TInt WriteDelimiter( const TDesC8& aDelimiter, TInt aCount );
       
   157 
       
   158     /**
       
   159     * Used when is need to save file or data to storage e.g. web page.
       
   160     * 16 bit.
       
   161     */
       
   162     IMPORT_C TInt SaveData(const TDesC& aData );
       
   163 
       
   164     /**
       
   165     * Used when is need to save file or data to storage e.g. web page.
       
   166     * 8 bit.
       
   167     */
       
   168     IMPORT_C TInt SaveData(const TDesC8& aData );
       
   169     
       
   170     /**
       
   171     * Get creation result.
       
   172     */
       
   173     IMPORT_C TInt CreationResult(TInt& aResult);
       
   174 
       
   175     /**
       
   176     * Get output type. Valid only if CreationResult returns KErrNone.
       
   177     */
       
   178     IMPORT_C TInt OutputType(CStifLogger::TOutput& aOutputType);
       
   179     
       
   180     /**
       
   181     * Log 16 bit _LIT information to some storage e.g. text file.
       
   182     */
       
   183     template<TInt S> TInt Log( const TLitC<S>& aLogInfo )
       
   184         { 
       
   185         return Log( CStifLogger::ENoStyle, (TDesC&)aLogInfo );
       
   186         };
       
   187 
       
   188     /**
       
   189     * Log 8 bit _LIT information to some storage e.g. text file.
       
   190     */
       
   191     template<TInt S> TInt Log( const TLitC8<S>& aLogInfo )
       
   192         { 
       
   193         return Log( CStifLogger::ENoStyle, (TDesC8&)aLogInfo );
       
   194         };
       
   195 
       
   196     /**
       
   197     * Log 16 bit _LIT information to some storage e.g. text file. There is
       
   198     * also parameter to styling text information e.g. text color.
       
   199     */
       
   200     template<TInt S> TInt Log( TInt aStyle, const TLitC<S>& aLogInfo )
       
   201         { 
       
   202         return Log( aStyle, (TDesC&)aLogInfo );
       
   203         };
       
   204 
       
   205     /**
       
   206     * Log 8 bit _LIT information to some storage e.g. text file.  There is
       
   207     * also parameter to styling text information e.g. text color.
       
   208     */
       
   209     template<TInt S> TInt Log( TInt aStyle, const TLitC8<S>& aLogInfo )
       
   210         { 
       
   211         return Log( aStyle, (TDesC8&)aLogInfo );
       
   212         };
       
   213     
       
   214 private:
       
   215     void OverwriteLoggerSettings( TLoggerSettings& aLoggerSettings,
       
   216                                                 TName& aTestPath,
       
   217                                                 TName& aTestFile,
       
   218                                                 CStifLogger::TLoggerType& aLoggerType,
       
   219                                                 CStifLogger::TOutput& aOutput,
       
   220                                                 TBool& aOverWrite,
       
   221                                                 TBool& aWithTimeStamp,
       
   222                                                 TBool& aWithLineBreak,
       
   223                                                 TBool& aWithEventRanking,
       
   224                                                 TBool& aThreadIdToLogFile,
       
   225                                                 TBool& aCreateLogDir,
       
   226                                                 TBool& aUnicode );
       
   227 
       
   228 	};
       
   229 
       
   230 	
       
   231 
       
   232 #endif  // __STFLOGGER_H__
       
   233