stif/Logger/src/StifLogger.cpp
changeset 0 a03f92240627
equal deleted inserted replaced
-1:000000000000 0:a03f92240627
       
     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 module contains implementation of CStifLogger 
       
    15 * class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32std.h>
       
    21 #include "StifLogger.h"
       
    22 #include "TxtLogger.h"
       
    23 #include "HtmlLogger.h"
       
    24 #include "DataLogger.h"
       
    25 #include "LoggerTracing.h"
       
    26 #include "LoggerOverFlow.h"
       
    27 #include "SettingServerClient.h"
       
    28 
       
    29 // EXTERNAL DATA STRUCTURES
       
    30 // None
       
    31 
       
    32 // EXTERNAL FUNCTION PROTOTYPES  
       
    33 // None
       
    34 
       
    35 // CONSTANTS
       
    36 // None
       
    37 
       
    38 // MACROS
       
    39 // None
       
    40 
       
    41 // LOCAL CONSTANTS AND MACROS
       
    42 // None
       
    43 
       
    44 // MODULE DATA STRUCTURES
       
    45 // None
       
    46 
       
    47 // LOCAL FUNCTION PROTOTYPES
       
    48 // None
       
    49 
       
    50 // FORWARD DECLARATIONS
       
    51 // None
       
    52 
       
    53 // ==================== LOCAL FUNCTIONS =======================================
       
    54 // None
       
    55 
       
    56 // ================= MEMBER FUNCTIONS =========================================
       
    57 
       
    58 /*
       
    59 -------------------------------------------------------------------------------
       
    60 
       
    61     Class: CStifLogger
       
    62 
       
    63     Method: CStifLogger
       
    64 
       
    65     Description: Default constructor
       
    66 
       
    67     C++ default constructor can NOT contain any code, that
       
    68     might leave.
       
    69 
       
    70     Parameters: None
       
    71     
       
    72     Return Values: None
       
    73 
       
    74     Errors/Exceptions: None
       
    75 
       
    76     Status: Approved
       
    77 
       
    78 -------------------------------------------------------------------------------
       
    79 */
       
    80 CStifLogger::CStifLogger()
       
    81     {
       
    82 
       
    83     }
       
    84 
       
    85 /*
       
    86 -------------------------------------------------------------------------------
       
    87 
       
    88     Class: CStifLogger
       
    89 
       
    90     Method: NewL
       
    91 
       
    92     Description: Two-phased constructor.
       
    93 
       
    94     Parameters: const TDesC& aTestPath: in: Path to logged information
       
    95                 const TDesC& aTestFile: in: Log name for information
       
    96                 TLoggerType aLoggerType: in: Log file type(txt, html,
       
    97                                              data)
       
    98                 TOutput aOutput: in: Output source(File)
       
    99                 TBool aOverWrite: in: Indicator to file overwrite
       
   100                 TBool aWithTimeStamp: in: Indicator to time stamp
       
   101                 TBool aWithLineBreak: in: Indicator to line break
       
   102                 TBool aWithEventRanking: in: Indicator to event ranking
       
   103                 TBool aThreadIdToLogFile: in: Indicator to thread id adding to
       
   104                                               end of the log file
       
   105                 TBool aCreateLogDir: in: Indicator to directory creation
       
   106                 TInt  aStaticBufferSize
       
   107                 TBool aUnicode: in: Indicator if file has to be in unicode format
       
   108 
       
   109     Return Values: CStifLogger* logger: pointer to CStifLogger object
       
   110 
       
   111     Errors/Exceptions: Leaves if aTestPath or aTestFile length is over KMaxName
       
   112                        Leaves if called serv.Connect() method fails
       
   113                        Leaves if called CHtmlLogger::NewL method fails
       
   114                        Leaves if called CDataLogger::NewL method fails
       
   115                        Leaves if called CTxtLogger::NewL method fails
       
   116 
       
   117     Status: Proposal
       
   118 
       
   119 -------------------------------------------------------------------------------
       
   120 */
       
   121 EXPORT_C CStifLogger* CStifLogger::NewL( const TDesC& aTestPath,
       
   122                                             const TDesC& aTestFile,
       
   123                                             TLoggerType aLoggerType,
       
   124                                             TOutput aOutput,
       
   125                                             TBool aOverWrite,
       
   126                                             TBool aWithTimeStamp,
       
   127                                             TBool aWithLineBreak,
       
   128                                             TBool aWithEventRanking,
       
   129                                             TBool aThreadIdToLogFile,
       
   130                                             TBool aCreateLogDir,
       
   131                                             TInt  aStaticBufferSize,
       
   132                                             TBool aUnicode )
       
   133     {
       
   134     if( KMaxName < aTestPath.Length() || KMaxName < aTestFile.Length() )
       
   135         {
       
   136         User::Leave( KErrArgument );
       
   137         }
       
   138 
       
   139     // Handle to Setting server.
       
   140     RSettingServer settingServer;
       
   141     // Connect to the Setting server and create session
       
   142     TInt ret = settingServer.Connect();
       
   143     if ( ret != KErrNone )
       
   144         {
       
   145         User::Leave( ret );
       
   146         }
       
   147     // Struct to StifLogger settigs.
       
   148     TLoggerSettings loggerSettings; 
       
   149     // Parse StifLogger defaults from STIF initialization file.
       
   150     ret = settingServer.GetLoggerSettings( loggerSettings );
       
   151     if ( ret != KErrNone )
       
   152         {
       
   153         User::Leave( ret );
       
   154         } 
       
   155 
       
   156     TName testPath = aTestPath;
       
   157     TName testFile = aTestFile;
       
   158 
       
   159     // Take in use the overwrite parameters
       
   160     OverwriteLoggerSettings( loggerSettings, testPath, testFile, aLoggerType,
       
   161                                 aOutput, aOverWrite, aWithTimeStamp,
       
   162                                 aWithLineBreak, aWithEventRanking,
       
   163                                 aThreadIdToLogFile, aCreateLogDir,
       
   164                                 aUnicode );
       
   165 
       
   166     // Close Setting server session
       
   167     settingServer.Close();
       
   168 
       
   169     // Html file logging
       
   170     if ( aLoggerType == EHtml )
       
   171         {
       
   172         // Create CHtmlLogger object logger
       
   173         CHtmlLogger* logger = CHtmlLogger::NewL( testPath,
       
   174                                                     testFile,
       
   175                                                     aLoggerType,
       
   176                                                     aOutput,
       
   177                                                     aOverWrite,
       
   178                                                     aWithTimeStamp,
       
   179                                                     aWithLineBreak,
       
   180                                                     aWithEventRanking,
       
   181                                                     aThreadIdToLogFile,
       
   182                                                     aCreateLogDir,
       
   183                                                     aStaticBufferSize,
       
   184                                                     aUnicode );
       
   185         return (CStifLogger*)logger;
       
   186         }
       
   187     // Data file
       
   188     else if ( aLoggerType == EData )
       
   189         {
       
   190         // Create CDataLogger object logger
       
   191         CDataLogger* logger = CDataLogger::NewL( testPath,
       
   192                                                     testFile,
       
   193                                                     aLoggerType,
       
   194                                                     aOutput,
       
   195                                                     aOverWrite,
       
   196                                                     aWithTimeStamp,
       
   197                                                     aWithLineBreak,
       
   198                                                     aWithEventRanking,
       
   199                                                     aThreadIdToLogFile,
       
   200                                                     aCreateLogDir,
       
   201                                                     aStaticBufferSize,
       
   202                                                     aUnicode );
       
   203         return (CStifLogger*)logger;
       
   204         }
       
   205     // For default: text file logging
       
   206     else
       
   207         {
       
   208         // Create CTxtLogger object logger
       
   209         CTxtLogger* logger = CTxtLogger::NewL( testPath,
       
   210                                                 testFile,
       
   211                                                 aLoggerType,
       
   212                                                 aOutput,
       
   213                                                 aOverWrite,
       
   214                                                 aWithTimeStamp,
       
   215                                                 aWithLineBreak,
       
   216                                                 aWithEventRanking,
       
   217                                                 aThreadIdToLogFile,
       
   218                                                 aCreateLogDir,
       
   219                                                 aStaticBufferSize,
       
   220                                                 aUnicode );
       
   221         return (CStifLogger*)logger;
       
   222         }
       
   223 
       
   224     }
       
   225 
       
   226 /*
       
   227 -------------------------------------------------------------------------------
       
   228 
       
   229     Class: CStifLogger
       
   230 
       
   231     Method: NewL
       
   232 
       
   233     Description: Two-phased constructor.
       
   234 
       
   235     TestEngine's and TestServer's are friend. For TestEngine's and
       
   236     TestServer's StifLogger creation.
       
   237 
       
   238     Parameters: const TDesC& aTestPath: in: Path to logged information
       
   239                 const TDesC& aTestFile: in: Log name for information
       
   240                 TLoggerSettings& aLoggerSettings: in: Struct for StifLogger
       
   241                                                       settigs
       
   242 
       
   243     Return Values: CStifLogger* logger: pointer to CStifLogger object
       
   244 
       
   245     Errors/Exceptions:  Leaves if called CHtmlLogger::NewL method fails
       
   246                         Leaves if called CDataLogger::NewL method fails
       
   247                         Leaves if called CTxtLogger::NewL method fails
       
   248 
       
   249     Status: Proposal
       
   250 
       
   251 -------------------------------------------------------------------------------
       
   252 */
       
   253 EXPORT_C CStifLogger* CStifLogger::NewL( const TDesC& aTestPath,
       
   254                                             const TDesC& aTestFile,
       
   255                                             TLoggerSettings& aLoggerSettings )
       
   256     {
       
   257     TInt cpu( 0 );
       
   258     HAL::Get( HALData::ECPU, cpu );
       
   259 
       
   260     // HW environment
       
   261     if ( cpu == HALData::ECPU_ARM )
       
   262         {
       
   263         // Html file logging
       
   264         if ( aLoggerSettings.iHardwareFormat == EHtml )
       
   265             {
       
   266             // Create CHtmlLogger object logger
       
   267             CHtmlLogger* logger = CHtmlLogger::NewL( aTestPath,
       
   268                                     aTestFile,
       
   269                                     aLoggerSettings.iHardwareFormat,
       
   270                                     aLoggerSettings.iHardwareOutput,
       
   271                                     aLoggerSettings.iOverwrite,
       
   272                                     aLoggerSettings.iTimeStamp,
       
   273                                     aLoggerSettings.iLineBreak,
       
   274                                     aLoggerSettings.iEventRanking,
       
   275                                     aLoggerSettings.iThreadId,
       
   276                                     aLoggerSettings.iCreateLogDirectories,
       
   277                                     0,
       
   278                                     aLoggerSettings.iUnicode );
       
   279             return (CStifLogger*)logger;
       
   280             }
       
   281         // Data file
       
   282         else if ( aLoggerSettings.iHardwareFormat == EData )
       
   283             {
       
   284             // Create CDataLogger object logger
       
   285             CDataLogger* logger = CDataLogger::NewL( aTestPath,
       
   286                                     aTestFile,
       
   287                                     aLoggerSettings.iHardwareFormat,
       
   288                                     aLoggerSettings.iHardwareOutput,
       
   289                                     aLoggerSettings.iOverwrite,
       
   290                                     aLoggerSettings.iTimeStamp,
       
   291                                     aLoggerSettings.iLineBreak,
       
   292                                     aLoggerSettings.iEventRanking,
       
   293                                     aLoggerSettings.iThreadId,
       
   294                                     aLoggerSettings.iCreateLogDirectories,
       
   295                                     0,
       
   296                                     aLoggerSettings.iUnicode );
       
   297             return (CStifLogger*)logger;
       
   298             }
       
   299         // For default: text file logging
       
   300         else
       
   301             {
       
   302             // Create CTxtLogger object logger
       
   303             CTxtLogger* logger = CTxtLogger::NewL( aTestPath,
       
   304                                     aTestFile,
       
   305                                     aLoggerSettings.iHardwareFormat,
       
   306                                     aLoggerSettings.iHardwareOutput,
       
   307                                     aLoggerSettings.iOverwrite,
       
   308                                     aLoggerSettings.iTimeStamp,
       
   309                                     aLoggerSettings.iLineBreak,
       
   310                                     aLoggerSettings.iEventRanking,
       
   311                                     aLoggerSettings.iThreadId,
       
   312                                     aLoggerSettings.iCreateLogDirectories,
       
   313                                     0,
       
   314                                     aLoggerSettings.iUnicode );
       
   315             return (CStifLogger*)logger;
       
   316             }
       
   317         } // End of HW environment branch
       
   318 
       
   319     // Wins environment ( cpu == HALData::ECPU_X86 )
       
   320     else
       
   321         {
       
   322         // Html file logging
       
   323         if ( aLoggerSettings.iEmulatorFormat == EHtml )
       
   324             {
       
   325             // Create CHtmlLogger object logger
       
   326             CHtmlLogger* logger = CHtmlLogger::NewL( aTestPath,
       
   327                                     aTestFile,
       
   328                                     aLoggerSettings.iEmulatorFormat,
       
   329                                     aLoggerSettings.iEmulatorOutput,
       
   330                                     aLoggerSettings.iOverwrite,
       
   331                                     aLoggerSettings.iTimeStamp,
       
   332                                     aLoggerSettings.iLineBreak,
       
   333                                     aLoggerSettings.iEventRanking,
       
   334                                     aLoggerSettings.iThreadId,
       
   335                                     aLoggerSettings.iCreateLogDirectories,
       
   336                                     0,
       
   337                                     aLoggerSettings.iUnicode );
       
   338             return (CStifLogger*)logger;
       
   339             }
       
   340         // Data file
       
   341         else if ( aLoggerSettings.iEmulatorFormat == EData )
       
   342             {
       
   343             // Create CDataLogger object logger
       
   344             CDataLogger* logger = CDataLogger::NewL( aTestPath,
       
   345                                     aTestFile,
       
   346                                     aLoggerSettings.iEmulatorFormat,
       
   347                                     aLoggerSettings.iEmulatorOutput,
       
   348                                     aLoggerSettings.iOverwrite,
       
   349                                     aLoggerSettings.iTimeStamp,
       
   350                                     aLoggerSettings.iLineBreak,
       
   351                                     aLoggerSettings.iEventRanking,
       
   352                                     aLoggerSettings.iThreadId,
       
   353                                     aLoggerSettings.iCreateLogDirectories,
       
   354                                     0,
       
   355                                     aLoggerSettings.iUnicode );
       
   356             return (CStifLogger*)logger;
       
   357             }
       
   358         // For default: text file logging
       
   359         else
       
   360             {
       
   361             // Create CTxtLogger object logger
       
   362             CTxtLogger* logger = CTxtLogger::NewL( aTestPath,
       
   363                                     aTestFile,
       
   364                                     aLoggerSettings.iEmulatorFormat,
       
   365                                     aLoggerSettings.iEmulatorOutput,
       
   366                                     aLoggerSettings.iOverwrite,
       
   367                                     aLoggerSettings.iTimeStamp,
       
   368                                     aLoggerSettings.iLineBreak,
       
   369                                     aLoggerSettings.iEventRanking,
       
   370                                     aLoggerSettings.iThreadId,
       
   371                                     aLoggerSettings.iCreateLogDirectories,
       
   372                                     0,
       
   373                                     aLoggerSettings.iUnicode );
       
   374             return (CStifLogger*)logger;
       
   375             }
       
   376         } // End of WINS environment branch
       
   377 
       
   378     }
       
   379 
       
   380 /*
       
   381 -------------------------------------------------------------------------------
       
   382 
       
   383     Class: CStifLogger
       
   384 
       
   385     Method: ~CStifLogger
       
   386 
       
   387     Description: Destructor
       
   388 
       
   389     Parameters: None
       
   390 
       
   391     Return Values: None
       
   392 
       
   393     Errors/Exceptions: None
       
   394 
       
   395     Status: Approved
       
   396 
       
   397 -------------------------------------------------------------------------------
       
   398 */
       
   399 CStifLogger::~CStifLogger()
       
   400     {
       
   401 
       
   402     delete iOutput;
       
   403     iOutput = 0;
       
   404     
       
   405     }
       
   406 
       
   407 /*
       
   408 -------------------------------------------------------------------------------
       
   409 
       
   410     Class: CStifLogger
       
   411 
       
   412     Method: OverwriteLoggerSettings
       
   413 
       
   414     Description: Local CStifLogger's method for StifLogger settings
       
   415                  overwriting.
       
   416 
       
   417     Overwrite parameters may set in TestFramework.ini file.
       
   418 
       
   419     Parameters: TLoggerSettings& aLoggerSettings: inout; Overwrite parameters
       
   420                 TName& aTestPath: inout: Path to logged information
       
   421                 TName& aTestFile: inout: Log file name for information
       
   422                 TLoggerType& aLoggerType: inout: Log file type(txt, html, data)
       
   423                 TOutput& aOutput: inout: Output source(File)
       
   424                 TBool& aOverWrite: inout: Indicator to file overwrite
       
   425                 TBool& aWithTimeStamp: inout: Indicator to time stamp
       
   426                 TBool& aWithLineBreak: inout: Indicator to line break
       
   427                 TBool& aWithEventRanking: inout: Indicator to event ranking
       
   428                 TBool& aThreadIdToLogFile: inout: Indicator to thread id adding to
       
   429                                                   end of the log file
       
   430                 TBool& aCreateLogDir: inout: Indicator to directory creation
       
   431                 TBool& aUnicode: inout: Indicator if log will be written to file in unicode format
       
   432     
       
   433     Return Values: None
       
   434 
       
   435     Errors/Exceptions: None 
       
   436 
       
   437     Status: Proposal
       
   438 
       
   439 -------------------------------------------------------------------------------
       
   440 */
       
   441 void CStifLogger::OverwriteLoggerSettings( TLoggerSettings& aLoggerSettings,
       
   442                                             TName& aTestPath,
       
   443                                             TName& aTestFile,
       
   444                                             TLoggerType& aLoggerType,
       
   445                                             TOutput& aOutput,
       
   446                                             TBool& aOverWrite,
       
   447                                             TBool& aWithTimeStamp,
       
   448                                             TBool& aWithLineBreak,
       
   449                                             TBool& aWithEventRanking,
       
   450                                             TBool& aThreadIdToLogFile,
       
   451                                             TBool& aCreateLogDir,
       
   452                                             TBool& aUnicode )
       
   453     {
       
   454     // Which environment is in use
       
   455     TInt cpu( 0 );
       
   456 
       
   457     // Indicator is file type remove acceptable operation
       
   458     TBool removeFileType( EFalse );
       
   459 
       
   460     // Get environment
       
   461     HAL::Get( HALData::ECPU, cpu );
       
   462 
       
   463     // HW environment
       
   464     if ( cpu == HALData::ECPU_ARM )
       
   465         {
       
   466         TInt pathLen = aTestPath.Length() + 
       
   467                         aLoggerSettings.iHardwarePath.Length();
       
   468 
       
   469         // Check that path overwrite setting is defined and length is legal
       
   470         if( aLoggerSettings.iIsDefined.iHwPath && pathLen < KMaxName )
       
   471             {
       
   472             TName newPath;
       
   473             newPath = aLoggerSettings.iHardwarePath;
       
   474             // Check is '\' the last character
       
   475             TInt ret( 0 );
       
   476             ret = newPath.LocateReverse( 92 );
       
   477             // Is '\' character founded
       
   478             if( ret != KErrNotFound )
       
   479                 {
       
   480                 // Is '\' last character
       
   481                 if( ret == ( newPath.Length() - 1 ) )
       
   482                     {
       
   483                     // delete last '\'
       
   484                     newPath.Delete( 
       
   485                         ( aLoggerSettings.iHardwarePath.Length() -1 ), 1 );
       
   486                     }
       
   487                 }
       
   488             // Removes drive letter if given and appends implemented path 
       
   489             TParse parse;
       
   490             parse.Set( aTestPath, NULL, NULL );
       
   491             // Path() return value starts with '\'
       
   492             newPath.Append( parse.Path() );
       
   493             aTestPath = newPath;
       
   494             }
       
   495         if( aLoggerSettings.iIsDefined.iHwFormat )
       
   496             {
       
   497             aLoggerType = aLoggerSettings.iHardwareFormat;
       
   498             // Remove file type if it is set
       
   499             removeFileType = ETrue;
       
   500             }
       
   501         if( aLoggerSettings.iIsDefined.iHwOutput )
       
   502             {
       
   503             aOutput = aLoggerSettings.iHardwareOutput;
       
   504             }
       
   505         }
       
   506 
       
   507     // Wins environment ( cpu == HALData::ECPU_X86 )
       
   508     else
       
   509         {
       
   510         TInt pathLen = aTestPath.Length() + 
       
   511                         aLoggerSettings.iEmulatorPath.Length();
       
   512 
       
   513         // Check that path overwrite setting is defined and length is legal
       
   514         if( aLoggerSettings.iIsDefined.iPath  && pathLen < KMaxName )
       
   515             {
       
   516             TName newPath;
       
   517             newPath = aLoggerSettings.iEmulatorPath;
       
   518             // Check is '\' the last character
       
   519             TInt ret( 0 );
       
   520             ret = newPath.LocateReverse( 92 );
       
   521             // Is '\' character founded
       
   522             if( ret != KErrNotFound )
       
   523                 {
       
   524                 // Is '\' last character
       
   525                 if( ret == ( newPath.Length() - 1 ) )
       
   526                     {
       
   527                     // delete last '\'
       
   528                     newPath.Delete( 
       
   529                         ( aLoggerSettings.iEmulatorPath.Length() -1 ), 1 );
       
   530                     }
       
   531                 }
       
   532             // Removes drive letter if given and appends implemented path
       
   533             TParse parse;
       
   534             parse.Set( aTestPath, NULL, NULL );
       
   535             // Path() return value starts with '\'
       
   536             newPath.Append( parse.Path() );
       
   537             aTestPath = newPath;
       
   538             }
       
   539         if( aLoggerSettings.iIsDefined.iFormat )
       
   540             {
       
   541             aLoggerType = aLoggerSettings.iEmulatorFormat;
       
   542             // Remove file type if it is set
       
   543             removeFileType = ETrue;
       
   544             }
       
   545         if( aLoggerSettings.iIsDefined.iOutput )
       
   546             {
       
   547             aOutput = aLoggerSettings.iEmulatorOutput;
       
   548             }
       
   549         }
       
   550 
       
   551     // Rest of the overwrite values
       
   552     if( aLoggerSettings.iIsDefined.iOverwrite )
       
   553         {
       
   554         aOverWrite = aLoggerSettings.iOverwrite;
       
   555         }
       
   556     if( aLoggerSettings.iIsDefined.iTimeStamp )
       
   557         {
       
   558         aWithTimeStamp = aLoggerSettings.iTimeStamp;
       
   559         }
       
   560     if( aLoggerSettings.iIsDefined.iLineBreak )
       
   561         {
       
   562         aWithLineBreak = aLoggerSettings.iLineBreak;
       
   563         }
       
   564     if( aLoggerSettings.iIsDefined.iEventRanking )
       
   565         {
       
   566         aWithEventRanking = aLoggerSettings.iEventRanking;
       
   567         }
       
   568     if( aLoggerSettings.iIsDefined.iThreadId )
       
   569         {
       
   570         aThreadIdToLogFile = aLoggerSettings.iThreadId;
       
   571         }
       
   572     if( aLoggerSettings.iIsDefined.iCreateLogDir )
       
   573         {
       
   574         aCreateLogDir = aLoggerSettings.iCreateLogDirectories;
       
   575         }
       
   576     if( aLoggerSettings.iIsDefined.iUnicode )
       
   577         {
       
   578         aUnicode = aLoggerSettings.iUnicode;
       
   579         }
       
   580 
       
   581     // Remove file type if allowed and if file type is set to filename
       
   582     if( removeFileType )
       
   583         {
       
   584         // Remove file type '.XXX' from file name if exist
       
   585         if( aTestFile.Find( _L( "." ) ) )
       
   586             {
       
   587             TParse parse;
       
   588             parse.Set( aTestFile, NULL, NULL );
       
   589             // Type length
       
   590             TInt length( 0 );
       
   591             // '.XXX'
       
   592             length = parse.Ext().Length();
       
   593             // Delete type
       
   594             aTestFile.Delete ( aTestFile.Length()-length, length );
       
   595             }
       
   596         }
       
   597 
       
   598     }
       
   599 
       
   600 /*
       
   601 -------------------------------------------------------------------------------
       
   602 
       
   603     Class: CStifLogger
       
   604 
       
   605     Method: Log
       
   606 
       
   607     Description: Log a 16 bit information.
       
   608 
       
   609     This log method accepts only one parameters
       
   610 
       
   611     Parameters: const TDesC aLogInfo: in: 8 bit data to be logged
       
   612 
       
   613     Return Values: TInt: Symbian error code.
       
   614 
       
   615     Errors/Exceptions:  None
       
   616 
       
   617     Status: Approved
       
   618 
       
   619 -------------------------------------------------------------------------------
       
   620 */
       
   621 EXPORT_C TInt CStifLogger::Log( const TDesC& aLogInfo )
       
   622     {
       
   623     // No text style info
       
   624     return Send( ENoStyle, aLogInfo );
       
   625 
       
   626     }
       
   627 
       
   628 /*
       
   629 -------------------------------------------------------------------------------
       
   630 
       
   631     Class: CStifLogger
       
   632 
       
   633     Method: Log
       
   634 
       
   635     Description: Log a 8 bit information.
       
   636 
       
   637     This log method accepts only one parameters
       
   638 
       
   639     Parameters: const TDesC8 aLogInfo: in: 8 bit data to be logged
       
   640 
       
   641     Return Values: TInt: Symbian error code.
       
   642 
       
   643     Errors/Exceptions:  None
       
   644 
       
   645     Status: Approved
       
   646 
       
   647 -------------------------------------------------------------------------------
       
   648 */
       
   649 EXPORT_C TInt CStifLogger::Log( const TDesC8& aLogInfo )
       
   650     {
       
   651     // No text style info
       
   652     return Send( ENoStyle, aLogInfo );
       
   653 
       
   654     }
       
   655 
       
   656 /*
       
   657 -------------------------------------------------------------------------------
       
   658 
       
   659     Class: CStifLogger
       
   660 
       
   661     Method: Log
       
   662 
       
   663     Description: Log a 16 bit information.
       
   664 
       
   665     There is also parameter to styling text information e.g. text color.
       
   666 
       
   667     Parameters: TInt aStyle: in: Logged text forming parameter
       
   668                 const TDesC aLogInfo: in: 16 bit data to be logged
       
   669 
       
   670     Return Values: TInt: Symbian error code.
       
   671 
       
   672     Errors/Exceptions:  None
       
   673 
       
   674     Status: Approved
       
   675 
       
   676 -------------------------------------------------------------------------------
       
   677 */
       
   678 EXPORT_C TInt CStifLogger::Log( TInt aStyle, const TDesC& aLogInfo )
       
   679     {
       
   680     return Send( aStyle, aLogInfo );
       
   681 
       
   682     }
       
   683 
       
   684 /*
       
   685 -------------------------------------------------------------------------------
       
   686 
       
   687     Class: CStifLogger
       
   688 
       
   689     Method: Log
       
   690 
       
   691     Description: Log a 8 bit information.
       
   692 
       
   693     There is also parameter to styling text information e.g. text color.
       
   694 
       
   695     Parameters: TInt aStyle: in: Logged text forming parameter
       
   696                 const TDesC8 aLogInfo: in: 8 bit data to be logged
       
   697 
       
   698     Return Values: TInt: Symbian error code.
       
   699 
       
   700     Errors/Exceptions:  None
       
   701 
       
   702     Status: Approved
       
   703 
       
   704 -------------------------------------------------------------------------------
       
   705 */
       
   706 EXPORT_C TInt CStifLogger::Log( TInt aStyle, const TDesC8& aLogInfo )
       
   707     {
       
   708     return Send( aStyle, aLogInfo );
       
   709 
       
   710     }
       
   711 
       
   712 /*
       
   713 -------------------------------------------------------------------------------
       
   714 
       
   715     Class: CStifLogger
       
   716 
       
   717     Method: Log
       
   718 
       
   719     Description: Log a 16 bit information.
       
   720 
       
   721     This log method accepts several parameters.
       
   722 
       
   723     Parameters: TRefByValue<const TDesC> aLogInfo: in: A templated class which 
       
   724                 encapsulates a reference to an object within a wrapper
       
   725 
       
   726     Return Values: TInt: Symbian error code.
       
   727 
       
   728     Errors/Exceptions:  TDesLoggerOverflowHandler called if logged information
       
   729                         is over KMaxLogData
       
   730 
       
   731     Status: Approved
       
   732 
       
   733 -------------------------------------------------------------------------------
       
   734 */
       
   735 EXPORT_C TInt CStifLogger::Log( TRefByValue<const TDesC> aLogInfo,... )
       
   736     {
       
   737     VA_LIST list;
       
   738     VA_START( list, aLogInfo );
       
   739     TLogInfo logInfo;
       
   740 
       
   741     // Create overflow handler. If the log information size is over the
       
   742     // KMaxLogData rest of the information will cut.
       
   743     TDesLoggerOverflowHandler overFlowHandler( this, 1 );
       
   744 
       
   745     // Parse parameters
       
   746     logInfo.AppendFormatList( aLogInfo, list, &overFlowHandler );
       
   747 
       
   748     // No text style info
       
   749     return Send( ENoStyle, logInfo );
       
   750 
       
   751     }
       
   752 
       
   753 /*
       
   754 -------------------------------------------------------------------------------
       
   755 
       
   756     Class: CStifLogger
       
   757 
       
   758     Method: Log
       
   759 
       
   760     Description: Log a 8 bit information.
       
   761 
       
   762     This log method accepts several parameters.
       
   763 
       
   764     Parameters: TRefByValue<const TDesC8> aLogInfo: in: A templated class which 
       
   765                 encapsulates a reference to an object within a wrapper
       
   766 
       
   767     Return Values: TInt: Symbian error code.
       
   768 
       
   769     Errors/Exceptions:  TDes8LoggerOverflowHandler called if logged information is 
       
   770                         over KMaxLogData
       
   771 
       
   772     Status: Approved
       
   773 
       
   774 -------------------------------------------------------------------------------
       
   775 */
       
   776 EXPORT_C TInt CStifLogger::Log( TRefByValue<const TDesC8> aLogInfo,... )
       
   777     {
       
   778     VA_LIST list;
       
   779     VA_START( list, aLogInfo );
       
   780     TLogInfo8 logInfo;
       
   781 
       
   782     // Create overflow handler. If the log information size is over the
       
   783     // KMaxLogData rest of the information will cut.
       
   784     TDes8LoggerOverflowHandler overFlowHandler( this, 1 );
       
   785 
       
   786     // Parse parameters
       
   787     logInfo.AppendFormatList( aLogInfo, list, &overFlowHandler );
       
   788 
       
   789     // No text style info
       
   790     return Send( ENoStyle, logInfo );
       
   791 
       
   792     }
       
   793 
       
   794 /*
       
   795 -------------------------------------------------------------------------------
       
   796 
       
   797     Class: CStifLogger
       
   798 
       
   799     Method: Log
       
   800 
       
   801     Description: Log a 16 bit information.
       
   802 
       
   803     This log method accepts several parameters. There is also parameter to
       
   804     styling text information e.g. text color.
       
   805 
       
   806     Parameters: TInt aStyle: in: Logged text forming parameter
       
   807                 TRefByValue<const TDesC> aLogInfo: in: A templated class 
       
   808                 which encapsulates a reference to an object
       
   809                 within a wrapper
       
   810 
       
   811     Return Values: TInt: Symbian error code.
       
   812 
       
   813     Errors/Exceptions:  TDesOverflowHandler called if logged information is
       
   814                         over KMaxLogData
       
   815 
       
   816     Status: Approved
       
   817 
       
   818 -------------------------------------------------------------------------------
       
   819 */
       
   820 EXPORT_C TInt CStifLogger::Log( TInt aStyle, 
       
   821                            TRefByValue<const TDesC> aLogInfo,... )
       
   822     {
       
   823     VA_LIST list;
       
   824     VA_START( list, aLogInfo );
       
   825     TLogInfo logInfo;
       
   826 
       
   827     // Create overflow handler. If the log information size is over the
       
   828     // KMaxLogData rest of the information will cut.
       
   829     TDesLoggerOverflowHandler overFlowHandler( this, 2 );
       
   830 
       
   831     // Parse parameters
       
   832     logInfo.AppendFormatList( aLogInfo, list, &overFlowHandler );
       
   833 
       
   834     return Send( aStyle, logInfo );
       
   835 
       
   836     }
       
   837 
       
   838 /*
       
   839 -------------------------------------------------------------------------------
       
   840 
       
   841     Class: CStifLogger
       
   842 
       
   843     Method: Log
       
   844 
       
   845     Description: Log a 8 bit information.
       
   846 
       
   847     This log method accepts several parameters. There is also parameter to
       
   848     styling text information e.g. text color.
       
   849 
       
   850     Parameters: TInt aStyle: in: Logged text forming parameter
       
   851                 TRefByValue<const TDesC8> aLogInfo: in: A templated class 
       
   852                 which encapsulates a reference to an object
       
   853                 within a wrapper
       
   854 
       
   855     Return Values: TInt: Symbian error code.
       
   856 
       
   857     Errors/Exceptions:  TDes8LoggerOverflowHandler called if logged information is
       
   858                         over KMaxLogData
       
   859 
       
   860     Status: Approved
       
   861 
       
   862 -------------------------------------------------------------------------------
       
   863 */
       
   864 EXPORT_C TInt CStifLogger::Log( TInt aStyle, 
       
   865                            TRefByValue<const TDesC8> aLogInfo,... )
       
   866     {
       
   867     VA_LIST list;
       
   868     VA_START( list, aLogInfo );
       
   869     TLogInfo8 logInfo;
       
   870 
       
   871     // Create overflow handler. If the log information size is over the
       
   872     // KMaxLogData rest of the information will cut.
       
   873     TDes8LoggerOverflowHandler overFlowHandler( this, 2 );
       
   874 
       
   875     // Parse parameters
       
   876     logInfo.AppendFormatList( aLogInfo, list, &overFlowHandler );
       
   877 
       
   878     return Send( aStyle, logInfo );
       
   879 
       
   880     }
       
   881 
       
   882 /*
       
   883 -------------------------------------------------------------------------------
       
   884 
       
   885     Class: CStifLogger
       
   886 
       
   887     Method: WriteDelimiter
       
   888 
       
   889     Description: Log a 16 bit delimiter.
       
   890 
       
   891     Log a delimiters required locations to the log information.
       
   892     This will be used if parameters are not given when calling this method.
       
   893 
       
   894     Parameters: const TDesC& aDelimiter: in: Logged delimiter(e.g. '#' or 'XO')
       
   895                 TInt aCount: in: Repeated count for delimiter
       
   896 
       
   897     Return Values: TInt: Symbian error code.
       
   898 
       
   899     Errors/Exceptions:  TDesLoggerOverflowHandler called if logged information
       
   900                         is over KMaxLogData.
       
   901 
       
   902     Status: Approved
       
   903 
       
   904 -------------------------------------------------------------------------------
       
   905 */
       
   906 EXPORT_C TInt CStifLogger::WriteDelimiter( const TDesC& aDelimiter, TInt aCount )
       
   907     {
       
   908     TLogInfo delimiter;
       
   909 
       
   910     // Create overflow handler. If the delimiter size expands over the
       
   911     // KMaxLogData the TDesLoggerOverflowHandler will call.
       
   912     TDesLoggerOverflowHandler overFlowHandler( this, 3 );
       
   913 
       
   914     // Create a delimiter
       
   915     for( TInt a = 0; a < aCount; a++ )
       
   916         {
       
   917         // If delimiter creation keeps under the KMaxLogData.
       
   918         // If not we use TDesLoggerOverflowHandler.
       
   919         if( ( a * aDelimiter.Length() ) < KMaxLogData ) 
       
   920             {
       
   921             delimiter.Append( aDelimiter );
       
   922             }
       
   923         // KMaxLogData is exceeded
       
   924         else
       
   925             {
       
   926             // If the title size is over the KMaxLogData default delimiter will
       
   927             // use. Use normal overflowhandler to print overflow information.
       
   928             TBuf<4> empty; // Not really used.
       
   929             overFlowHandler.Overflow( empty );
       
   930             delimiter.Copy( 
       
   931                 _L( "##################################################" ) );
       
   932             break;
       
   933             }
       
   934         }
       
   935 
       
   936     // No text style info
       
   937     return Send( ENoStyle, delimiter );
       
   938 
       
   939     }
       
   940 
       
   941 /*
       
   942 -------------------------------------------------------------------------------
       
   943 
       
   944     Class: CStifLogger
       
   945 
       
   946     Method: WriteDelimiter
       
   947 
       
   948     Description: Log a 8 bit delimiter.
       
   949 
       
   950     Log a delimiters required locations to the log information.
       
   951 
       
   952     Parameters: const TDesC8& aDelimiter: in: Logged delimiter
       
   953                                               (e.g. '#' or 'XO')
       
   954                 TInt aCount: in: Repeated count for delimiter
       
   955 
       
   956     Return Values: TInt: Symbian error code.
       
   957 
       
   958     Errors/Exceptions:  TDes8LoggerOverflowHandler called if logged information is
       
   959                         over KMaxLogData.
       
   960 
       
   961     Status: Approved
       
   962 
       
   963 -------------------------------------------------------------------------------
       
   964 */
       
   965 EXPORT_C TInt CStifLogger::WriteDelimiter( const TDesC8& aDelimiter, TInt aCount )
       
   966     {
       
   967     TLogInfo8 delimiter;
       
   968 
       
   969     // Create overflow handler. If the delimiter size expands over the
       
   970     // KMaxLogData the TDesLoggerOverflowHandler will call.
       
   971     TDes8LoggerOverflowHandler overFlowHandler( this, 3 );
       
   972 
       
   973     // Create a delimiter
       
   974     for( TInt a = 0; a < aCount; a++ )
       
   975         {
       
   976         // If delimiter creation keeps under the KMaxLogData.
       
   977         // If not we use TDesLoggerOverflowHandler.
       
   978         if( ( a * aDelimiter.Length() ) < KMaxLogData ) 
       
   979             {
       
   980             delimiter.Append( aDelimiter );
       
   981             }
       
   982         // KMaxLogData is exceeded
       
   983         else
       
   984             {
       
   985             // If the title size is over the KMaxLogData default delimiter will
       
   986             // use. Use normal overflowhandler to print overflow information.
       
   987             TBuf8<4> empty; // Not really used.
       
   988             overFlowHandler.Overflow( empty );
       
   989             delimiter.Copy( 
       
   990                 _L8( "##################################################" ) );
       
   991             break;
       
   992             }
       
   993         }
       
   994 
       
   995     // No text style info
       
   996     return Send( ENoStyle, delimiter );
       
   997 
       
   998     }
       
   999 
       
  1000 /*
       
  1001 -------------------------------------------------------------------------------
       
  1002 
       
  1003     Class: CStifLogger
       
  1004 
       
  1005     Method: SaveData
       
  1006 
       
  1007     Description: Save file or data( 16 bit ).
       
  1008 
       
  1009     Used when is need to save file or data to storage e.g. web page.
       
  1010 
       
  1011     Parameters: TDesC& aData: in: Data to be saved
       
  1012     
       
  1013     Return Values: TInt: Symbian error code.
       
  1014 
       
  1015     Errors/Exceptions:  None
       
  1016 
       
  1017     Status: Approved
       
  1018 
       
  1019 -------------------------------------------------------------------------------
       
  1020 */
       
  1021 EXPORT_C TInt CStifLogger::SaveData( TDesC& aData )
       
  1022     {
       
  1023     // No text style info
       
  1024     return Send( ENoStyle, aData );
       
  1025 
       
  1026     }
       
  1027 
       
  1028 /*
       
  1029 -------------------------------------------------------------------------------
       
  1030 
       
  1031     Class: CStifLogger
       
  1032 
       
  1033     Method: SaveData
       
  1034 
       
  1035     Description: Save file or data( 8 bit ).
       
  1036 
       
  1037     Used when is need to save file or data to storage e.g. web page.
       
  1038 
       
  1039     Parameters: TDesC8& aData: in: Data to be saved
       
  1040     
       
  1041     Return Values: TInt: Symbian error code.
       
  1042 
       
  1043     Errors/Exceptions:  None
       
  1044 
       
  1045     Status: Approved
       
  1046 
       
  1047 -------------------------------------------------------------------------------
       
  1048 */
       
  1049 EXPORT_C TInt CStifLogger::SaveData( TDesC8& aData )
       
  1050     {
       
  1051     // No text style info
       
  1052     return Send( ENoStyle, aData );
       
  1053 
       
  1054     }
       
  1055 
       
  1056 /*
       
  1057 -------------------------------------------------------------------------------
       
  1058 
       
  1059     Class: CStifLogger
       
  1060 
       
  1061     Method: CreationResult
       
  1062 
       
  1063     Description: Return StifLogger creation result.
       
  1064 
       
  1065     Parameters: None
       
  1066     
       
  1067     Return Values: StifLogger creation result
       
  1068 
       
  1069     Errors/Exceptions:  None
       
  1070 
       
  1071     Status: Approved
       
  1072 
       
  1073 -------------------------------------------------------------------------------
       
  1074 */
       
  1075 EXPORT_C TInt CStifLogger::CreationResult()
       
  1076     {
       
  1077      
       
  1078     TOutput outputType;
       
  1079     return iOutput->OutputCreationResult( outputType );
       
  1080     
       
  1081     }
       
  1082     
       
  1083 /*
       
  1084 -------------------------------------------------------------------------------
       
  1085 
       
  1086     Class: CStifLogger
       
  1087 
       
  1088     Method: OutputType
       
  1089 
       
  1090     Description: Get output type. Valid only if CreationResult returns KErrNone.
       
  1091 
       
  1092     Parameters: TOutput& aOutput
       
  1093     
       
  1094     Return Values: StifLogger creation result
       
  1095 
       
  1096     Errors/Exceptions:  None
       
  1097 
       
  1098     Status: Approved
       
  1099 
       
  1100 -------------------------------------------------------------------------------
       
  1101 */
       
  1102 EXPORT_C CStifLogger::TOutput CStifLogger::OutputType()
       
  1103     {
       
  1104     
       
  1105     TOutput outputType;
       
  1106     iOutput->OutputCreationResult( outputType );
       
  1107     return outputType;
       
  1108     
       
  1109     }
       
  1110 
       
  1111 // End of File