videoeditorengine/audioeditorengine/util/inc/Logfile.h
changeset 9 d87d32eab1a9
parent 0 951a5db380a0
equal deleted inserted replaced
0:951a5db380a0 9:d87d32eab1a9
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "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 * Ixonos Plc
       
    14 *
       
    15 * Description:  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __LOGFILE_H__
       
    21 #define __LOGFILE_H__
       
    22 
       
    23 #include <f32file.h>
       
    24 #include <charconv.h>
       
    25 
       
    26 class CCnvCharacterSetConverter;
       
    27 
       
    28 // Link with the following libraries: EFSRV.LIB HAL.LIB CHARCONV.LIB           
       
    29 
       
    30 /*! 
       
    31   @class CLogFile
       
    32   
       
    33   @discussion Class to generate a text file containing logging information
       
    34   */
       
    35 class CLogFile : public CBase
       
    36     {
       
    37 public:
       
    38 /*!
       
    39   @function NewL
       
    40    
       
    41   @discussion Create a CLogFile object
       
    42   @param aFileName the name of the file to create
       
    43   @param aInitialiseLog if true, and the log file already exists, previous
       
    44   contents will be deleted. If false, append to any existing contents
       
    45   @result a pointer to the created instance of CLogFile
       
    46   */
       
    47     static CLogFile* NewL(const TDesC& aFileName, TBool aInitialiseLog);
       
    48 
       
    49 /*!
       
    50   @function NewLC
       
    51    
       
    52   @discussion Create a CLogFile object
       
    53   @param aFileName the name of the file to create
       
    54   @param aInitialiseLog if true, and the log file already exists, previous
       
    55   contents will be deleted. If false, append to any existing contents
       
    56   @result a pointer to the created instance of CLogFile
       
    57   */
       
    58     static CLogFile* NewLC(const TDesC& aFileName, TBool aInitialiseLog);
       
    59 
       
    60 /*!
       
    61   @function ~CLogFile
       
    62   
       
    63   @discussion Destroy the object and release all memory objects
       
    64   */
       
    65     ~CLogFile();
       
    66 
       
    67 /*!
       
    68   @function Log
       
    69   
       
    70   @discussion Append the byte to the log file (if not a printable char, it will be logged as ascii-hex)
       
    71   @param aByte the byte to log
       
    72   */
       
    73     void Log(TUint8 aByte);
       
    74 
       
    75 /*!
       
    76   @function Log
       
    77   
       
    78   @discussion Append the integer to the log file (logged as ascii-hex)
       
    79   @param aNumber the integer to log
       
    80   */
       
    81     void Log(TUint aNumber);
       
    82 
       
    83 /*!
       
    84   @function Log
       
    85   
       
    86   @discussion Append text to the log file
       
    87   @param aText the text to log
       
    88   */
       
    89     void Log(const TDesC8& aText);
       
    90 
       
    91 /*!
       
    92   @function Log
       
    93   
       
    94   @discussion Append text to the log file
       
    95   @param aText the text to log
       
    96   */
       
    97     void Log(const TDesC& aText);
       
    98 
       
    99 /*!
       
   100   @function LogTime
       
   101   
       
   102   @discussion Append a timestamp to the log file.
       
   103   Timestamps are in seconds with three decimal places (but resolution is limited to system timer tick period)
       
   104   */
       
   105     void LogTime();
       
   106 
       
   107 /*!
       
   108   @function LogBytes
       
   109 
       
   110   @discussion Append the bytes to the log file (non-printable bytes will be logged as ascii-hex)
       
   111   @param aBuffer the bytes to log
       
   112   @param fastWrite writes data directly to file (no print out)
       
   113   */
       
   114     void LogBytes(const TDesC8& aBuffer, TBool fastWrite);
       
   115 
       
   116 /*!
       
   117   @function LogNewline
       
   118 
       
   119   @discussion Start a newline in the log file
       
   120   */
       
   121     void LogNewline();
       
   122 
       
   123 /*!
       
   124   @function SetAutoFlush
       
   125 
       
   126   @discussion Turn AutoFlush on or off. AutoFlush will automatically flush the log file after each write
       
   127   @param aOn if true turns AutoFlush on
       
   128   */
       
   129     void SetAutoFlush(TBool aOn);
       
   130 
       
   131 /*!
       
   132   @function SetAutoTimeStamp
       
   133 
       
   134   @discussion Turn AutoTimeStamp on or off. AutoTimeStamp will add a timestamp to the start of each new line in the log
       
   135   @param aOn if true turn AutoTimeStamp on
       
   136   */
       
   137     void SetAutoTimeStamp(TBool aOn);
       
   138 
       
   139 /*!
       
   140   @function SetAutoNewline
       
   141 
       
   142   @discussion Turn AutoNewline on or off. AutoNewline starts a new line after each log operation
       
   143   @param aOn if true turn AutoNewline on
       
   144   */
       
   145     void SetAutoNewline(TBool aOn);
       
   146 
       
   147 /*!
       
   148   @function StaticLogL
       
   149 
       
   150   @discussion Static option to append text to the log file
       
   151   @param aFileName the file to append to
       
   152   @param aText the text to append
       
   153   */
       
   154     static void StaticLogL(const TDesC& aFileName, const TDesC8& aText);
       
   155 
       
   156 /*!
       
   157   @function StaticLogL
       
   158 
       
   159   @discussion Static option to append text to the log file
       
   160   @param aFileName the file to append to
       
   161   @param aText the text to append
       
   162   */
       
   163     static void StaticLogL(const TDesC& aFileName, const TDesC& aText);
       
   164 
       
   165 
       
   166 private:
       
   167 /*!
       
   168   @function CLogFile
       
   169   
       
   170   @discussion Perform the first phase of two phase construction 
       
   171   */
       
   172     CLogFile();
       
   173 /*!
       
   174   @function ConstructL
       
   175   
       
   176   @discussion  Perform the second phase construction of a CLogFile object
       
   177   @param aFileName the file to open
       
   178   @param aInitialiseLog if true, and the log file already exists, previous
       
   179   contents will be deleted. If false, append to any existing contents
       
   180   */
       
   181     void ConstructL(const TDesC& aFileName, TBool aInitialiseLog);
       
   182 /*!
       
   183   @function LogTimeInternal
       
   184 
       
   185   @discussion Internal function to log time
       
   186   */
       
   187     void LogTimeInternal();
       
   188 /*!
       
   189   @function LogTextInternal
       
   190 
       
   191   @discussion Internal function to log text
       
   192   @param aText the text to log
       
   193   */
       
   194     void LogTextInternal(const TDesC8& aText);
       
   195 /*!
       
   196   @function LogByteInternal
       
   197 
       
   198   @discussion internal function to log a byte
       
   199   @param aByte the byte to log
       
   200   */
       
   201     void LogByteInternal(TUint8 aByte, TBool acsiiMode = EFalse);
       
   202 /*!
       
   203   @function LogIntInternal
       
   204 
       
   205   @discussion Internal function to log an integer
       
   206   @param aNumber the integer to log
       
   207   */
       
   208     void LogIntInternal(TUint aNumber);
       
   209 /*!
       
   210   @function StartWrite
       
   211 
       
   212   @discussion Perform any initial operation before the main log operation
       
   213   */
       
   214     void StartWrite();
       
   215 
       
   216 /*!
       
   217   @function EndWrite
       
   218 
       
   219   @discussion Perform any tidying up operations after the main log operation
       
   220   */
       
   221     void EndWrite();
       
   222 
       
   223 /*!
       
   224   @function Write
       
   225 
       
   226   @discussion Do the actual writing, and associated error checking
       
   227   @param aText the text to write
       
   228   */
       
   229     void Write(const TDesC8& aText);
       
   230 
       
   231 private:
       
   232 /*!
       
   233   @var iLogFile handle to the log file
       
   234   */
       
   235     RFile       iLogFile;
       
   236 
       
   237 /*!
       
   238   @var iSession file server session
       
   239   */
       
   240     RFs         iSession;
       
   241 
       
   242 /*!
       
   243   @var iLogMillisecsPerTick number of millisecs per system timer tick
       
   244   */
       
   245     TInt        iLogMillisecsPerTick;
       
   246 
       
   247 /*!
       
   248   @var iAutoFlush flag - AutoFlush on
       
   249   */
       
   250     TBool       iAutoFlush;
       
   251 
       
   252 /*!
       
   253   @var iAutoTimestamp flag - AutoTimeStamp on
       
   254   */
       
   255     TBool       iAutoTimestamp;
       
   256 
       
   257 /*!
       
   258   @var iAutoNewline flag - AutoNewline on
       
   259   */
       
   260     TBool       iAutoNewline;
       
   261 
       
   262 /*!
       
   263   @var iCheckNestDepth internal to check StartWrite and EndWrite have been called correctly
       
   264   */
       
   265     TInt        iCheckNestDepth;
       
   266 /*!
       
   267   @var iCharacterConverter converts between unicode and non-unicode characters
       
   268   */
       
   269     CCnvCharacterSetConverter* iCharacterConverter;
       
   270 
       
   271 /*!
       
   272   @var iConverterAvailability flag indicating if conversion is able to occur
       
   273   */
       
   274     CCnvCharacterSetConverter::TAvailability iConverterAvailability;
       
   275     };
       
   276 
       
   277 #endif // __LOGFILE_H__