testexecfw/stf/stffw/logger/STFLoggingServer/src/DataLogger.cpp
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: This module contains implementation of CDataLogger 
       
    15 * class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32std.h>
       
    21 #include "DataLogger.h"
       
    22 #include "Output.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 // None
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 // None
       
    29 
       
    30 // CONSTANTS
       
    31 // None
       
    32 
       
    33 // MACROS
       
    34 // None
       
    35 
       
    36 // LOCAL CONSTANTS AND MACROS
       
    37 // None
       
    38 
       
    39 // MODULE DATA STRUCTURES
       
    40 // None
       
    41 
       
    42 // LOCAL FUNCTION PROTOTYPES
       
    43 // None
       
    44 
       
    45 // FORWARD DECLARATIONS
       
    46 // None
       
    47 
       
    48 // ==================== LOCAL FUNCTIONS =======================================
       
    49 // None
       
    50 
       
    51 
       
    52 // ================= MEMBER FUNCTIONS =========================================
       
    53 
       
    54 /*
       
    55 -------------------------------------------------------------------------------
       
    56 
       
    57     Class: CDataLogger
       
    58 
       
    59     Method: CDataLogger
       
    60 
       
    61     Description: Default constructor
       
    62 
       
    63     C++ default constructor can NOT contain any code, that
       
    64     might leave.
       
    65 
       
    66     Parameters: COutput* output: in: Output source
       
    67 
       
    68     Return Values: None
       
    69 
       
    70     Errors/Exceptions: None
       
    71 
       
    72     Status: Approved
       
    73 
       
    74 -------------------------------------------------------------------------------
       
    75 */
       
    76 CDataLogger::CDataLogger( COutput* output )
       
    77     {
       
    78     	iOutput = output;
       
    79     }
       
    80 
       
    81 /*
       
    82 -------------------------------------------------------------------------------
       
    83 
       
    84     Class: CDataLogger
       
    85 
       
    86     Method: ConstructL
       
    87 
       
    88     Description: Symbian OS second phase constructor
       
    89 
       
    90     Symbian OS default constructor can leave.
       
    91 
       
    92     Parameters: None
       
    93 
       
    94     Return Values: None
       
    95 
       
    96     Errors/Exceptions: None
       
    97 
       
    98     Status: Approved
       
    99 
       
   100 -------------------------------------------------------------------------------
       
   101 */
       
   102 void CDataLogger::ConstructL()
       
   103     {
       
   104     //Nothing to do.
       
   105     }
       
   106 
       
   107 /*
       
   108 -------------------------------------------------------------------------------
       
   109 
       
   110     Class: CDataLogger
       
   111 
       
   112     Method: NewL
       
   113 
       
   114     Description: Two-phased constructor.
       
   115 
       
   116     Parameters: const TDesC& aTestPath: in: Log path
       
   117                 const TDesC& aTestFile: in: Log filename
       
   118                 TLoggerType aLoggerType: in: File type
       
   119                 TOutput aOutput: in: Output source
       
   120                 TBool aOverWrite: in: For file overwrite
       
   121                 TBool aWithTimeStamp: in: For timestamp
       
   122                 TBool aWithLineBreak: in: For line break
       
   123                 TBool aWithEventRanking: in: For events ranking to file
       
   124                 TBool aThreadIdToLogFile: in: Indicator to thread id adding to
       
   125                                               end of the log file
       
   126                 TBool aCreateLogDir: in: Indicator to directory creation
       
   127                 TInt  aStaticBufferSize
       
   128                 TBool aUnicode: not used: Indicator if file has to be in unicode format.
       
   129 
       
   130     Return Values: CDataLogger*: pointer to CDataLogger object
       
   131 
       
   132     Errors/Exceptions: Leaves if called COutput::NewL method fails
       
   133 
       
   134     Status: Proposal
       
   135 
       
   136 -------------------------------------------------------------------------------
       
   137 */
       
   138 CDataLogger* CDataLogger::NewL( const TDesC& aTestPath,
       
   139                                 const TDesC& aTestFile,
       
   140                                 CStifLogger::TLoggerType aLoggerType,
       
   141                                 CStifLogger::TOutput aOutput,
       
   142                                 TBool aOverWrite,
       
   143                                 TBool aWithTimeStamp,
       
   144                                 TBool aWithLineBreak,
       
   145                                 TBool aWithEventRanking,
       
   146                                 TBool aThreadIdToLogFile,
       
   147                                 TBool aCreateLogDir,
       
   148                                 TInt aStaticBufferSize,
       
   149                                 TBool /*aUnicode*/,
       
   150                                 TInt aThreadId)
       
   151     {
       
   152     __TRACE( KInfo, ( _L( "STIFLOGGER: Creating data logger" ) ) );
       
   153 
       
   154     aWithTimeStamp = EFalse;    // Time stamp not allowed in data logging
       
   155     aWithLineBreak = EFalse;    // Line break not allowed in data logging
       
   156     aWithEventRanking = EFalse; // Event ranking not allowed in data logging
       
   157 
       
   158     TBool aUnicode(EFalse); //For data type unicode is not allowed
       
   159     // Create COutput object output
       
   160     COutput* output = COutput::NewL( aTestPath,
       
   161                                         aTestFile,
       
   162                                         aLoggerType,
       
   163                                         aOutput,
       
   164                                         aOverWrite,
       
   165                                         aWithTimeStamp,
       
   166                                         aWithLineBreak,
       
   167                                         aWithEventRanking,
       
   168                                         aThreadIdToLogFile,
       
   169                                         aCreateLogDir,
       
   170                                         aStaticBufferSize,
       
   171                                         aUnicode,
       
   172                                         aThreadId);
       
   173                                         
       
   174     CleanupStack::PushL( output ); 
       
   175 
       
   176 	__ASSERT_ALWAYS( output != NULL, User::Leave( KErrNotFound ) );
       
   177     // Create CDataLogger object dataLogger and bind to COutput
       
   178     CDataLogger* dataLogger = new (ELeave) CDataLogger( output );
       
   179     // DATA logger owns output object and it will be destroyed in STIFLogger
       
   180     // destructor.
       
   181     CleanupStack::Pop( output ); 
       
   182 
       
   183     CleanupStack::PushL( dataLogger );
       
   184     dataLogger->ConstructL();
       
   185     CleanupStack::Pop( dataLogger );
       
   186     
       
   187     
       
   188     return dataLogger;
       
   189 
       
   190     }
       
   191 
       
   192 /*
       
   193 -------------------------------------------------------------------------------
       
   194 
       
   195     Class: CDataLogger
       
   196 
       
   197     Method: ~CDataLogger
       
   198 
       
   199     Description: Destructor
       
   200 
       
   201     Parameters: None
       
   202 
       
   203     Return Values: None
       
   204 
       
   205     Errors/Exceptions: None
       
   206 
       
   207     Status: Approved
       
   208 
       
   209 -------------------------------------------------------------------------------
       
   210 */
       
   211 CDataLogger::~CDataLogger()
       
   212     {
       
   213     }
       
   214 
       
   215 /*
       
   216 -------------------------------------------------------------------------------
       
   217 
       
   218     Class: CDataLogger
       
   219 
       
   220     Method: Send
       
   221 
       
   222     Description: Send style information and 16 bit data to the output module.
       
   223 
       
   224     Parameters: TInt TStyle: in: Text forming
       
   225                 const TDesC& aData: in: Data to be logged
       
   226 
       
   227     Return Values: TInt: Symbian error code.
       
   228 
       
   229     Errors/Exceptions: None
       
   230 
       
   231     Status: Approved
       
   232 
       
   233 -------------------------------------------------------------------------------
       
   234 */
       
   235 TInt CDataLogger::Send( TInt /*TStyle*/, const TDesC& aData )
       
   236     {
       
   237     // No text styling implemented
       
   238     return iOutput->Write( EFalse, ETrue, EFalse, aData );
       
   239 
       
   240     }
       
   241 
       
   242 /*
       
   243 -------------------------------------------------------------------------------
       
   244 
       
   245     Class: CDataLogger
       
   246 
       
   247     Method: Send
       
   248 
       
   249     Description: Send style information and 8 bit data to the output module.
       
   250 
       
   251     Parameters: TInt TStyle: in: Text forming
       
   252                 const TDesC8& aData: in: Data to be logged
       
   253 
       
   254     Return Values: TInt: Symbian error code.
       
   255 
       
   256     Errors/Exceptions: None
       
   257 
       
   258     Status: Approved
       
   259 
       
   260 -------------------------------------------------------------------------------
       
   261 */
       
   262 TInt CDataLogger::Send( TInt /*TStyle*/, const TDesC8& aData )
       
   263     {
       
   264     // No text styling implemented
       
   265     return iOutput->Write( EFalse, ETrue, ETrue, aData );
       
   266 
       
   267     }
       
   268 
       
   269 // ================= OTHER EXPORTED FUNCTIONS =================================
       
   270 // None
       
   271 
       
   272 // End of File