stif/Logger/inc/FileOutput.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 0 a03f92240627
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     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: This file contains the header file of the CFileOutput.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef FILEOUTPUT_H
       
    19 #define FILEOUTPUT_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <f32file.h>
       
    23 
       
    24 #include "Output.h"
       
    25 
       
    26 // CONSTANTS
       
    27 // None
       
    28 
       
    29 // MACROS
       
    30 // None
       
    31 
       
    32 // DATA TYPES
       
    33 // None
       
    34 
       
    35 // FUNCTION PROTOTYPES
       
    36 // None
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 // None
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 // DESCRIPTION
       
    44 // CFileOutput is a STIF Test Framework StifLogger class.
       
    45 // Class contains a file logging operations.
       
    46 class CFileOutput 
       
    47             :public COutput
       
    48     {
       
    49     public:     // Enumerations
       
    50 
       
    51     private:    // Enumerations
       
    52 
       
    53     public:     // Constructors and destructor
       
    54 
       
    55         /**
       
    56         * Two-phased constructor.
       
    57         */
       
    58         static CFileOutput* NewL( const TDesC& aTestPath,
       
    59                                     const TDesC& aTestFile,
       
    60                                     CStifLogger::TLoggerType aLoggerType,
       
    61                                     TBool aOverWrite,
       
    62                                     TBool aWithTimeStamp,
       
    63                                     TBool aWithLineBreak,
       
    64                                     TBool aWithEventRanking,
       
    65                                     TBool aThreadIdToLogFile,
       
    66                                     TBool aCreateLogDir,
       
    67                                     TInt  aStaticBufferSize,
       
    68                                     TBool aUnicode );
       
    69 
       
    70         /**
       
    71         * Destructor.
       
    72         */
       
    73         ~CFileOutput();
       
    74 
       
    75     public:     // New functions
       
    76 
       
    77         /**
       
    78         * Create a directory.
       
    79         */
       
    80         void CreateDirectoryL( const TDesC& aTestPath );
       
    81 
       
    82         /**
       
    83         * Open an existing file.
       
    84         */
       
    85         void OpenExistingFileL( const TDesC& aTestPath,
       
    86                                 const TDesC& aTestFile );
       
    87 
       
    88         /**
       
    89         * Create a new file.
       
    90         */
       
    91         void CreateNewFileL( const TDesC& aTestPath, const TDesC& aTestFile );
       
    92 
       
    93         /**
       
    94         * Write log information or data to the file.
       
    95         * 16 bit.
       
    96         */
       
    97         TInt Write( TBool aWithTimeStamp,
       
    98                     TBool aWithLineBreak,
       
    99                     TBool aWithEventRanking,
       
   100                     const TDesC& aData );
       
   101 
       
   102         /**
       
   103         * Write log information or data to the file.
       
   104         * 8 bit.
       
   105         */
       
   106         TInt Write( TBool aWithTimeStamp,
       
   107                     TBool aWithLineBreak,
       
   108                     TBool aWithEventRanking,
       
   109                     const TDesC8& aData );
       
   110 
       
   111         /**
       
   112         * Add event ranking, specify number to line (1-byte version).
       
   113         */
       
   114         void EventRanking( TPtr8& aData );
       
   115 
       
   116         /**
       
   117         * Add event ranking, specify number to line (2-byte version).
       
   118         */
       
   119         void EventRanking( TPtr& aData );
       
   120 
       
   121         /**
       
   122         * Add date, time and line break to data (1-byte version).
       
   123         */
       
   124         void AddTimeStampToData( TPtr8& aData );
       
   125 
       
   126         /**
       
   127         * Add date, time and line break to data (2-byte version).
       
   128         */
       
   129         void AddTimeStampToData( TPtr& aData );
       
   130 
       
   131         /**
       
   132         * Get date and time.
       
   133         */
       
   134         void GetDateAndTime( TStifLoggerTimeStamp& aDataAndTime );
       
   135 
       
   136         /**
       
   137         * Make file type.
       
   138         */
       
   139         void FileType( const TDesC& aTestFile, TFileType& aFileType );
       
   140 
       
   141         /**
       
   142         * Generate thread id to test file name.
       
   143         */
       
   144         void TestFileWithThreadId( const TDesC& aTestFile,
       
   145                                     TFileName& aNewTestFile );
       
   146 
       
   147     public:     // Functions from base classes
       
   148 
       
   149     protected:  // New functions
       
   150 
       
   151     protected:  // Functions from base classes
       
   152 
       
   153     private:
       
   154 
       
   155         /**
       
   156         * C++ default constructor.
       
   157         */
       
   158         CFileOutput( CStifLogger::TLoggerType aLoggerType,
       
   159                         TBool aWithTimeStamp,
       
   160                         TBool aWithLineBreak,
       
   161                         TBool aWithEventRanking,
       
   162                         TBool aThreadIdToLogFile );
       
   163 
       
   164         /**
       
   165         * By default Symbian OS constructor is private.
       
   166         */
       
   167         void ConstructL( const TDesC& aTestPath,
       
   168                             const TDesC& aTestFile,
       
   169                             TBool aOverWrite,
       
   170                             TBool aCreateLogDir,
       
   171                             TInt aStaticBufferSize,
       
   172                             TBool aUnicode );
       
   173 
       
   174     public:     // Data
       
   175 
       
   176     protected:  // Data
       
   177 
       
   178     private:    // Data
       
   179 
       
   180         /**
       
   181         * Log file directory name, file name and file type.
       
   182         */
       
   183         TFileName iFileAndDirName;
       
   184 
       
   185         /**
       
   186         * Indicates file type.
       
   187         */
       
   188         CStifLogger::TLoggerType iLoggerType;
       
   189 
       
   190         /**
       
   191         * Time stamp indicator.
       
   192         */
       
   193         TBool iWithTimeStamp;
       
   194 
       
   195         /**
       
   196         * Line break indicator.
       
   197         */
       
   198         TBool iWithLineBreak;
       
   199 
       
   200         /**
       
   201         * Event ranking indicator.
       
   202         */
       
   203         TBool iWithEventRanking;
       
   204 
       
   205         /**
       
   206         * Indicator to thread id adding to end of the log file
       
   207         */
       
   208         TBool iThreadIdToLogFile;
       
   209 
       
   210         /**
       
   211         * Indicator to thread id adding to end of the log file
       
   212         */
       
   213         TBool iCreateLogDir;
       
   214 
       
   215         /**
       
   216         * For the file handling
       
   217         */
       
   218         RFile iFile;
       
   219 
       
   220         /**
       
   221         * For the file session handling
       
   222         */
       
   223         RFs iFileSession;
       
   224 
       
   225         /**
       
   226         * Is file open indicator
       
   227         */
       
   228         TInt iIsFileOpen;
       
   229 
       
   230        /**
       
   231         * DataHBuf for logging purposes
       
   232         */
       
   233         HBufC8 * iDataHBuf8;
       
   234 
       
   235 		// @js
       
   236         TInt iStaticBufferSize;
       
   237 
       
   238        /**
       
   239         * Determines if file has to be in unicode format
       
   240         */
       
   241         TBool iUnicode;
       
   242 
       
   243        /**
       
   244         * DataHBuf for logging purposes
       
   245         */
       
   246         HBufC16* iDataHBuf16;
       
   247 
       
   248     public:     // Friend classes
       
   249 
       
   250     protected:  // Friend classes
       
   251 
       
   252     private:    // Friend classes
       
   253 
       
   254     };
       
   255 
       
   256 #endif      // FILEOUTPUT_H
       
   257 
       
   258 // End of File