testexecfw/stf/stffw/logger/STFLoggingServer/src/StifLoggerBase.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 CStifLoggerBase 
       
    15 * class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32std.h>
       
    21 #include "StifLoggerBase.h"
       
    22 #include "TxtLogger.h"
       
    23 #include "HtmlLogger.h"
       
    24 #include "DataLogger.h"
       
    25 #include "LoggerTracing.h"
       
    26 #include "LoggerOverFlow.h"
       
    27 
       
    28 /*
       
    29 -------------------------------------------------------------------------------
       
    30 
       
    31     Class: CStifLoggerBase
       
    32 
       
    33     Method: CStifLoggerBase
       
    34 
       
    35     Description: Default constructor
       
    36 
       
    37     C++ default constructor can NOT contain any code, that
       
    38     might leave.
       
    39 
       
    40     Parameters: None
       
    41     
       
    42     Return Values: None
       
    43 
       
    44     Errors/Exceptions: None
       
    45 
       
    46     Status: Approved
       
    47 
       
    48 -------------------------------------------------------------------------------
       
    49 */
       
    50 CStifLoggerBase::CStifLoggerBase()
       
    51     {
       
    52 
       
    53     }
       
    54 
       
    55 /*
       
    56 -------------------------------------------------------------------------------
       
    57 
       
    58     Class: CStifLoggerBase
       
    59 
       
    60     Method: NewL
       
    61 
       
    62     Description: Two-phased constructor.
       
    63 
       
    64     Parameters: const TDesC& aTestPath: in: Path to logged information
       
    65                 const TDesC& aTestFile: in: Log name for information
       
    66                 TLoggerType aLoggerType: in: Log file type(txt, html,
       
    67                                              data)
       
    68                 TOutput aOutput: in: Output source(File)
       
    69                 TBool aOverWrite: in: Indicator to file overwrite
       
    70                 TBool aWithTimeStamp: in: Indicator to time stamp
       
    71                 TBool aWithLineBreak: in: Indicator to line break
       
    72                 TBool aWithEventRanking: in: Indicator to event ranking
       
    73                 TBool aThreadIdToLogFile: in: Indicator to thread id adding to
       
    74                                               end of the log file
       
    75                 TBool aCreateLogDir: in: Indicator to directory creation
       
    76                 TInt  aStaticBufferSize
       
    77                 TBool aUnicode: in: Indicator if file has to be in unicode format
       
    78 
       
    79     Return Values: CStifLoggerBase* logger: pointer to CStifLoggerBase object
       
    80 
       
    81     Errors/Exceptions: Leaves if aTestPath or aTestFile length is over KMaxName
       
    82                        Leaves if called serv.Connect() method fails
       
    83                        Leaves if called CHtmlLogger::NewL method fails
       
    84                        Leaves if called CDataLogger::NewL method fails
       
    85                        Leaves if called CTxtLogger::NewL method fails
       
    86 
       
    87     Status: Proposal
       
    88 
       
    89 -------------------------------------------------------------------------------
       
    90 */
       
    91 EXPORT_C CStifLoggerBase* CStifLoggerBase::NewL( const TDesC& aTestPath,
       
    92                                             const TDesC& aTestFile,
       
    93                                             CStifLogger::TLoggerType aLoggerType,
       
    94                                             CStifLogger::TOutput aOutput,
       
    95                                             TBool aOverWrite,
       
    96                                             TBool aWithTimeStamp,
       
    97                                             TBool aWithLineBreak,
       
    98                                             TBool aWithEventRanking,
       
    99                                             TBool aThreadIdToLogFile,
       
   100                                             TBool aCreateLogDir,
       
   101                                             TInt  aStaticBufferSize,
       
   102                                             TBool aUnicode,
       
   103                                             TInt aThreadId)
       
   104     {
       
   105     if( KMaxName < aTestPath.Length() || KMaxName < aTestFile.Length() )
       
   106         {
       
   107         User::Leave( KErrArgument );
       
   108         }
       
   109 
       
   110 
       
   111 
       
   112     // Html file logging
       
   113     if ( aLoggerType == CStifLogger::EHtml )
       
   114         {
       
   115         // Create CHtmlLogger object logger
       
   116         CHtmlLogger* logger = CHtmlLogger::NewL( aTestPath,
       
   117                                                     aTestFile,
       
   118                                                     aLoggerType,
       
   119                                                     aOutput,
       
   120                                                     aOverWrite,
       
   121                                                     aWithTimeStamp,
       
   122                                                     aWithLineBreak,
       
   123                                                     aWithEventRanking,
       
   124                                                     aThreadIdToLogFile,
       
   125                                                     aCreateLogDir,
       
   126                                                     aStaticBufferSize,
       
   127                                                     aUnicode,
       
   128                                                     aThreadId);
       
   129         return (CStifLoggerBase*)logger;
       
   130         }
       
   131     // Data file
       
   132     else if ( aLoggerType == CStifLogger::EData )
       
   133         {
       
   134         // Create CDataLogger object logger
       
   135         CDataLogger* logger = CDataLogger::NewL( aTestPath,
       
   136                                                     aTestFile,
       
   137                                                     aLoggerType,
       
   138                                                     aOutput,
       
   139                                                     aOverWrite,
       
   140                                                     aWithTimeStamp,
       
   141                                                     aWithLineBreak,
       
   142                                                     aWithEventRanking,
       
   143                                                     aThreadIdToLogFile,
       
   144                                                     aCreateLogDir,
       
   145                                                     aStaticBufferSize,
       
   146                                                     aUnicode,
       
   147                                                     aThreadId);
       
   148         return (CStifLoggerBase*)logger;
       
   149         }
       
   150     // For default: text file logging
       
   151     else
       
   152         {
       
   153         // Create CTxtLogger object logger
       
   154         CTxtLogger* logger = CTxtLogger::NewL( aTestPath,
       
   155                                                 aTestFile,
       
   156                                                 aLoggerType,
       
   157                                                 aOutput,
       
   158                                                 aOverWrite,
       
   159                                                 aWithTimeStamp,
       
   160                                                 aWithLineBreak,
       
   161                                                 aWithEventRanking,
       
   162                                                 aThreadIdToLogFile,
       
   163                                                 aCreateLogDir,
       
   164                                                 aStaticBufferSize,
       
   165                                                 aUnicode,
       
   166                                                 aThreadId);
       
   167         return (CStifLoggerBase*)logger;
       
   168         }
       
   169 
       
   170     }
       
   171 
       
   172 /*
       
   173 -------------------------------------------------------------------------------
       
   174 
       
   175     Class: CStifLoggerBase
       
   176 
       
   177     Method: ~CStifLoggerBase
       
   178 
       
   179     Description: Destructor
       
   180 
       
   181     Parameters: None
       
   182 
       
   183     Return Values: None
       
   184 
       
   185     Errors/Exceptions: None
       
   186 
       
   187     Status: Approved
       
   188 
       
   189 -------------------------------------------------------------------------------
       
   190 */
       
   191 CStifLoggerBase::~CStifLoggerBase()
       
   192     {
       
   193 
       
   194     if(iOutput)
       
   195         {
       
   196         delete iOutput;
       
   197         iOutput = 0;
       
   198         }
       
   199     
       
   200     }
       
   201 
       
   202 
       
   203 /*
       
   204 -------------------------------------------------------------------------------
       
   205 
       
   206     Class: CStifLoggerBase
       
   207 
       
   208     Method: Log
       
   209 
       
   210     Description: Log a 16 bit information.
       
   211 
       
   212     There is also parameter to styling text information e.g. text color.
       
   213 
       
   214     Parameters: TInt aStyle: in: Logged text forming parameter
       
   215                 const TDesC aLogInfo: in: 16 bit data to be logged
       
   216 
       
   217     Return Values: TInt: Symbian error code.
       
   218 
       
   219     Errors/Exceptions:  None
       
   220 
       
   221     Status: Approved
       
   222 
       
   223 -------------------------------------------------------------------------------
       
   224 */
       
   225 EXPORT_C TInt CStifLoggerBase::Log( TInt aStyle, const TDesC& aLogInfo )
       
   226     {
       
   227     return Send( aStyle, aLogInfo );
       
   228 
       
   229     }
       
   230 
       
   231 /*
       
   232 -------------------------------------------------------------------------------
       
   233 
       
   234     Class: CStifLoggerBase
       
   235 
       
   236     Method: Log
       
   237 
       
   238     Description: Log a 8 bit information.
       
   239 
       
   240     There is also parameter to styling text information e.g. text color.
       
   241 
       
   242     Parameters: TInt aStyle: in: Logged text forming parameter
       
   243                 const TDesC8 aLogInfo: in: 8 bit data to be logged
       
   244 
       
   245     Return Values: TInt: Symbian error code.
       
   246 
       
   247     Errors/Exceptions:  None
       
   248 
       
   249     Status: Approved
       
   250 
       
   251 -------------------------------------------------------------------------------
       
   252 */
       
   253 EXPORT_C TInt CStifLoggerBase::Log( TInt aStyle, const TDesC8& aLogInfo )
       
   254     {
       
   255     return Send( aStyle, aLogInfo );
       
   256 
       
   257     }
       
   258 
       
   259 /*
       
   260 -------------------------------------------------------------------------------
       
   261 
       
   262     Class: CStifLoggerBase
       
   263 
       
   264     Method: CreationResult
       
   265 
       
   266     Description: Return StifLoggerBase creation result.
       
   267 
       
   268     Parameters: None
       
   269     
       
   270     Return Values: StifLoggerBase creation result
       
   271 
       
   272     Errors/Exceptions:  None
       
   273 
       
   274     Status: Approved
       
   275 
       
   276 -------------------------------------------------------------------------------
       
   277 */
       
   278 EXPORT_C TInt CStifLoggerBase::CreationResult()
       
   279     {
       
   280      
       
   281     CStifLogger::TOutput outputType;
       
   282     return iOutput->OutputCreationResult( outputType );
       
   283     
       
   284     }
       
   285     
       
   286 /*
       
   287 -------------------------------------------------------------------------------
       
   288 
       
   289     Class: CStifLoggerBase
       
   290 
       
   291     Method: OutputType
       
   292 
       
   293     Description: Get output type. Valid only if CreationResult returns KErrNone.
       
   294 
       
   295     Parameters: TOutput& aOutput
       
   296     
       
   297     Return Values: StifLoggerBase creation result
       
   298 
       
   299     Errors/Exceptions:  None
       
   300 
       
   301     Status: Approved
       
   302 
       
   303 -------------------------------------------------------------------------------
       
   304 */
       
   305 EXPORT_C CStifLogger::TOutput CStifLoggerBase::OutputType()
       
   306     {
       
   307     
       
   308     CStifLogger::TOutput outputType;
       
   309     iOutput->OutputCreationResult( outputType );
       
   310     return outputType;
       
   311     
       
   312     }
       
   313 
       
   314 // End of File