sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Client / server logging for Test Framework sl@0: // NOTE : does NOT include secure API changes in EKA2 sl@0: // sl@0: // sl@0: sl@0: sl@0: // Test system includes sl@0: #include sl@0: sl@0: // do not export if Unit Testing sl@0: #if defined (__TSU_TESTFRAMEWORK__) sl@0: #undef EXPORT_C sl@0: #define EXPORT_C sl@0: #endif sl@0: sl@0: /** sl@0: * sl@0: * HTML font formatting strings sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: _LIT(KResultPass, ""); sl@0: _LIT(KResultFail, ""); sl@0: _LIT(KResultInconclusive, ""); sl@0: _LIT(KResultUndefined, ""); sl@0: _LIT(KResultEnd, ""); sl@0: _LIT(KResultNonHtml, ""); sl@0: sl@0: _LIT(KResultKnownFailure, ""); //A new TVerdict for a known failed test sl@0: sl@0: // logging macro used only for verdicts - not for external use sl@0: #define VER_PRINTF(r1, r2, r3) LogExtra(__FILE8__, __LINE__, ESevrVer, _L("%S%S%S\n"), (r1), (r2), (r3)) sl@0: sl@0: /** sl@0: * sl@0: * Static constructor for CLog. sl@0: * sl@0: * sl@0: * @return "CLog*" sl@0: * The constructed CLog sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C CLog* CLog::NewL() sl@0: { sl@0: CLog* self = new(ELeave) CLog; sl@0: self->Construct(); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Static NewLC constructor for CLog. sl@0: * sl@0: * sl@0: * @return "CLog*" sl@0: * The constructed CLog sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C CLog* CLog::NewLC() sl@0: { sl@0: CLog* self = new(ELeave) CLog; sl@0: CleanupStack::PushL(self); sl@0: self->Construct(); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Second-phase constructor for CLog. sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::Construct() sl@0: { sl@0: iLogStatus = 0; // no outputs enabled yet sl@0: iSeverity = ESevrAll; sl@0: //Do we need to put information about source file & #line? sl@0: //Default is yes. sl@0: iLogFlags = ELogPutSrcInfo | ELogHtmlMode; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Destructor for CLog. sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C CLog::~CLog() sl@0: { sl@0: // tell server to close logs here sl@0: iClientSession.Close(); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Open a new test log. sl@0: * sl@0: * @param "const TDesC& aLogName" sl@0: * Log file or console name sl@0: * sl@0: * @param "TInt aLogMode" sl@0: * Log modes (a bitmask of TTestFrameworkLogMode). sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::OpenLogFileL(const TDesC& aLogName, TInt aLogMode) sl@0: { sl@0: User::LeaveIfError(iClientSession.Connect()); sl@0: sl@0: iClientSession.OpenLog(aLogName, aLogMode); sl@0: // get and store the log status - this will determine whether we sl@0: // e.g. do any formatting for file output sl@0: iLogStatus = iClientSession.LogStatus(); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Open an existing test log. sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::OpenLogFileL() sl@0: { sl@0: User::LeaveIfError(iClientSession.Connect()); sl@0: iLogStatus = iClientSession.LogStatus(); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Set put source info (i.e. traceable logging). sl@0: * sl@0: * @param "TBool aPutSrcInfo" sl@0: * Put source info on or off. sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::SetPutSrcInfo(TBool aPutSrcInfo) sl@0: { sl@0: if(aPutSrcInfo) sl@0: iLogFlags |= ELogPutSrcInfo; sl@0: else sl@0: iLogFlags &= ~ELogPutSrcInfo; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Set HTML logging mode. sl@0: * sl@0: * @param "TBool aArg" sl@0: * HTML mode on or off. sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::SetHtmlLogMode(TBool aArg) sl@0: { sl@0: if(aArg) sl@0: iLogFlags |= ELogHtmlMode; sl@0: else sl@0: iLogFlags &= ~ELogHtmlMode; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Get HTML logging mode. sl@0: * sl@0: * @return "TBool" sl@0: * HTML mode on or off. sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C TBool CLog::HtmlLogMode() const sl@0: { sl@0: return ((iLogFlags & ELogHtmlMode) != 0); sl@0: } sl@0: sl@0: sl@0: /** sl@0: * sl@0: * General logging function. sl@0: * sl@0: * @param "TRefByValue aFmt" sl@0: * Printf-style format. sl@0: * sl@0: * @param "..." sl@0: * Variable print parameters sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::Log(TRefByValue aFmt, ...) sl@0: { sl@0: VA_LIST aList; sl@0: VA_START(aList, aFmt); sl@0: sl@0: TIntegrationTestLog16Overflow overflow16; sl@0: sl@0: // decode formatted data for display on console sl@0: TBuf lineBuf; sl@0: lineBuf = KNullDesC; sl@0: lineBuf.AppendFormatList(aFmt, aList, &overflow16); sl@0: sl@0: // write to the console sl@0: if(iLogStatus & ELogConsoleFull) sl@0: iClientSession.WriteLog(lineBuf, ELogToConsole); sl@0: sl@0: // write to log file sl@0: WriteFormat(_L("%S\n"), &lineBuf); sl@0: sl@0: VA_END(aList); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * General logging function with severity. sl@0: * sl@0: * @param "TInt aSeverity" sl@0: * Severity level required to log sl@0: * sl@0: * @param "TRefByValue aFmt" sl@0: * Printf-style format. sl@0: * sl@0: * @param "..." sl@0: * Variable print parameters sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::Log(TInt aSeverity, TRefByValue aFmt, ...) sl@0: { sl@0: VA_LIST aList; sl@0: VA_START(aList, aFmt); sl@0: sl@0: if(LogSeverity::IsActive(aSeverity, Severity())) sl@0: { sl@0: Log(aFmt, aList); sl@0: } sl@0: sl@0: VA_END(aList); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * General logging function. sl@0: * sl@0: * @param "TRefByValue aFmt" sl@0: * Printf-style format. sl@0: * sl@0: * @param "VA_LIST aList" sl@0: * Variable print parameters sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::Log(TRefByValue aFmt, VA_LIST aList) sl@0: { sl@0: // decode formatted data for display on console sl@0: TBuf lineBuf; sl@0: TIntegrationTestLog16Overflow overflow16; sl@0: sl@0: lineBuf = KNullDesC; sl@0: lineBuf.AppendFormatList(aFmt, aList, &overflow16); sl@0: sl@0: // write to log file sl@0: WriteFormat(_L("%S\n"),&lineBuf); sl@0: sl@0: // write to the console sl@0: if(iLogStatus & ELogConsoleFull) sl@0: iClientSession.WriteLog(lineBuf, ELogToConsole); sl@0: sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Traceable logging function sl@0: * sl@0: * Should be used for macros only sl@0: * sl@0: * @param "const TText8* aFile" sl@0: * Source code file name sl@0: * sl@0: * @param "TInt aLine" sl@0: * Source code line sl@0: * sl@0: * @param "TInt aSeverity" sl@0: * Severity level required to log sl@0: * sl@0: * @param "TRefByValue aFmt" sl@0: * Printf-style format. sl@0: * sl@0: * @param "VA_LIST aList" sl@0: * Variable print parameters sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: #ifdef EXCLUDE_FOR_UNITTEST sl@0: EXPORT_C void CLog::LogExtra(const TText8* /*aFile*/, TInt /*aLine*/, TInt /*aSeverity*/, sl@0: TRefByValue /*aFmt*/, VA_LIST /*aList*/) sl@0: { sl@0: } sl@0: #else sl@0: EXPORT_C void CLog::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity, sl@0: TRefByValue aFmt, VA_LIST aList) sl@0: { sl@0: if(LogSeverity::IsActive(aSeverity, Severity())) sl@0: { sl@0: sl@0: TIntegrationTestLog16Overflow overflow16; sl@0: sl@0: // decode formatted data for display on console sl@0: TBuf lineBuf; sl@0: sl@0: lineBuf = KNullDesC; sl@0: lineBuf.AppendFormatList(aFmt, aList, &overflow16); sl@0: sl@0: // write to the console sl@0: if(iLogStatus & ELogConsoleFull) sl@0: WriteLogConsole(lineBuf); sl@0: sl@0: // log severity sl@0: TBuf<1> charSevr; sl@0: switch(aSeverity) sl@0: { sl@0: case ESevrVer: sl@0: charSevr = _L("V"); sl@0: break; sl@0: case ESevrErr: sl@0: charSevr = _L("E"); sl@0: break; sl@0: case ESevrWarn: sl@0: charSevr = _L("W"); sl@0: break; sl@0: case ESevrInfo: sl@0: default: sl@0: charSevr = _L("I"); sl@0: break; sl@0: } sl@0: sl@0: // Do we need to put information about source file & #line? sl@0: if(iLogFlags & ELogPutSrcInfo) sl@0: { // Braces used to scope lifetime of TBuf objects sl@0: TPtrC8 fileName8(aFile); sl@0: TBuf<256> fileName; sl@0: TParse printFileName; sl@0: fileName.Copy(fileName8); // TText8->TBuf16 sl@0: // We don't need full file name. sl@0: printFileName.Set(fileName, NULL, NULL) ; sl@0: fileName.Copy(printFileName.NameAndExt()) ; sl@0: // write to log file sl@0: WriteFormat(_L("%S\t%S\t%d\t%S\n"), &charSevr, &fileName, aLine, &lineBuf); sl@0: } sl@0: else sl@0: { sl@0: // write to log file sl@0: WriteFormat(_L("%S\t%S\n"), &charSevr, &lineBuf); sl@0: } sl@0: } sl@0: } sl@0: #endif // EXCLUDE_FOR_UNITTEST sl@0: sl@0: /** sl@0: * sl@0: * Traceable logging function with variable param list. sl@0: * sl@0: * Should be used for macros only sl@0: * sl@0: * @param "const TText8* aFile" sl@0: * Source code file name sl@0: * sl@0: * @param "TInt aLine" sl@0: * Source code line sl@0: * sl@0: * @param "TInt aSeverity" sl@0: * Severity level required to log sl@0: * sl@0: * @param "TRefByValue aFmt" sl@0: * Printf-style format. sl@0: * sl@0: * @param "..." sl@0: * Variable print parameters sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity, sl@0: TRefByValue aFmt,...) sl@0: { sl@0: VA_LIST aList; sl@0: VA_START(aList, aFmt); sl@0: LogExtra(aFile, aLine, aSeverity, aFmt, aList); sl@0: VA_END(aList); sl@0: } sl@0: sl@0: sl@0: /** sl@0: * sl@0: * Write a test result highlighted to the log. sl@0: * sl@0: * @param "TVerdict aVerdict" sl@0: * The test verdict. sl@0: * sl@0: * @param "TRefByValue aFmt" sl@0: * Printf-style format. sl@0: * sl@0: * @param "..." sl@0: * Variable print parameters sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::LogResult(TVerdict aVerdict, TRefByValue aFmt, ...) sl@0: { sl@0: VA_LIST aList; sl@0: VA_START(aList, aFmt); sl@0: sl@0: TIntegrationTestLog16Overflow iOverflow16; sl@0: sl@0: // decode formatted data for display on console sl@0: TBuf lineBuf; sl@0: lineBuf.AppendFormatList(aFmt, aList, &iOverflow16); sl@0: sl@0: // write to the console sl@0: iClientSession.WriteLog(lineBuf, ELogToConsole); sl@0: sl@0: // write to log file sl@0: if(iLogFlags & ELogHtmlMode) sl@0: { sl@0: switch(aVerdict) sl@0: { sl@0: case EPass: sl@0: VER_PRINTF(&KResultPass(), &lineBuf, &KResultEnd()); sl@0: break; sl@0: case EFail: sl@0: VER_PRINTF(&KResultFail(), &lineBuf, &KResultEnd()); sl@0: break; sl@0: case EInconclusive: sl@0: case ETestSuiteError: sl@0: case EAbort: sl@0: VER_PRINTF(&KResultInconclusive(), &lineBuf, &KResultEnd()); sl@0: break; sl@0: case EKnownFailure: //A new TVerdict for a known failed test sl@0: VER_PRINTF(&KResultKnownFailure(), &lineBuf, &KResultEnd()); sl@0: break; sl@0: sl@0: default: // undefined sl@0: VER_PRINTF(&KResultUndefined(), &lineBuf, &KResultEnd()); sl@0: break; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: VER_PRINTF(&KResultNonHtml(), &lineBuf, &KResultNonHtml()); sl@0: } sl@0: VA_END(aList); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Make a readable string out of an EPOC error code. sl@0: * sl@0: * @param "TInt aError" sl@0: * The error code sl@0: * sl@0: * @return "TPtrC" sl@0: * The error code as a readable string sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C TPtrC CLog::EpocErrorToText(TInt aError) sl@0: { sl@0: switch (aError) sl@0: { sl@0: case KErrNone: sl@0: return _L("KErrNone"); sl@0: case KErrNotFound: sl@0: return _L("KErrNotFound"); sl@0: case KErrGeneral: sl@0: return _L("KErrGeneral"); sl@0: case KErrCancel: sl@0: return _L("KErrCancel"); sl@0: case KErrNoMemory: sl@0: return _L("KErrNoMemory"); sl@0: case KErrNotSupported: sl@0: return _L("KErrNotSupported"); sl@0: case KErrArgument: sl@0: return _L("KErrArgument"); sl@0: case KErrTotalLossOfPrecision: sl@0: return _L("KErrTotalLossOfPrecision"); sl@0: case KErrBadHandle: sl@0: return _L("KErrBadHandle"); sl@0: case KErrOverflow: sl@0: return _L("KErrOverflow"); sl@0: case KErrUnderflow: sl@0: return _L("KErrUnderflow"); sl@0: case KErrAlreadyExists: sl@0: return _L("KErrAlreadyExists"); sl@0: case KErrPathNotFound: sl@0: return _L("KErrPathNotFound"); sl@0: case KErrDied: sl@0: return _L("KErrDied"); sl@0: case KErrInUse: sl@0: return _L("KErrInUse"); sl@0: case KErrServerTerminated: sl@0: return _L("KErrServerTerminated"); sl@0: case KErrServerBusy: sl@0: return _L("KErrServerBusy"); sl@0: case KErrCompletion: sl@0: return _L("KErrCompletion"); sl@0: case KErrNotReady: sl@0: return _L("KErrNotReady"); sl@0: case KErrUnknown: sl@0: return _L("KErrUnknown"); sl@0: case KErrCorrupt: sl@0: return _L("KErrCorrupt"); sl@0: case KErrAccessDenied: sl@0: return _L("KErrAccessDenied"); sl@0: case KErrLocked: sl@0: return _L("KErrLocked"); sl@0: case KErrWrite: sl@0: return _L("KErrWrite"); sl@0: case KErrDisMounted: sl@0: return _L("KErrDisMounted"); sl@0: case KErrEof: sl@0: return _L("KErrEof"); sl@0: case KErrDiskFull: sl@0: return _L("KErrDiskFull"); sl@0: case KErrBadDriver: sl@0: return _L("KErrBadDriver"); sl@0: case KErrBadName: sl@0: return _L("KErrBadName"); sl@0: case KErrCommsLineFail: sl@0: return _L("KErrCommsLineFail"); sl@0: case KErrCommsFrame: sl@0: return _L("KErrCommsFrame"); sl@0: case KErrCommsOverrun: sl@0: return _L("KErrCommsOverrun"); sl@0: case KErrCommsParity: sl@0: return _L("KErrCommsParity"); sl@0: case KErrTimedOut: sl@0: return _L("KErrTimedOut"); sl@0: case KErrCouldNotConnect: sl@0: return _L("KErrCouldNotConnect"); sl@0: case KErrCouldNotDisconnect: sl@0: return _L("KErrCouldNotDisconnect"); sl@0: case KErrDisconnected: sl@0: return _L("KErrDisconnected"); sl@0: case KErrBadLibraryEntryPoint: sl@0: return _L("KErrBadLibraryEntryPoint"); sl@0: case KErrBadDescriptor: sl@0: return _L("KErrBadDescriptor"); sl@0: case KErrAbort: sl@0: return _L("KErrAbort"); sl@0: case KErrTooBig: sl@0: return _L("KErrTooBig"); sl@0: default: sl@0: return _L("Unknown"); sl@0: } // end switch sl@0: } sl@0: sl@0: sl@0: /** sl@0: * sl@0: * Make a readable string out of a test verdict. sl@0: * sl@0: * @param "TVerdict aTestVerdict" sl@0: * The test verdict sl@0: * sl@0: * @return "TPtrC" sl@0: * The test verdict as a readable string sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C TPtrC CLog::TestResultText(TVerdict aTestVerdict) sl@0: { sl@0: switch (aTestVerdict) sl@0: { sl@0: case EPass: sl@0: return _L("PASS"); sl@0: case EFail: sl@0: return _L("FAIL"); sl@0: case EInconclusive: sl@0: return _L("INCONCLUSIVE"); sl@0: case ETestSuiteError: sl@0: return _L("TEST_SUITE_ERROR"); sl@0: case EAbort: sl@0: return _L("ABORT"); sl@0: case EKnownFailure: //A new TVerdict for a known failed test sl@0: return _L("KNOWN_Failure"); //using lower case in 'Failure' can remove the confusion on 'savres2html.bat' making test summary sl@0: default: sl@0: return _L("undefined"); sl@0: sl@0: } sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Write blank lines to the log. sl@0: * sl@0: * @param "TInt number" sl@0: * Number of lines to write sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::LogBlankLine(TInt aNumber) sl@0: { sl@0: for (TInt i = 0; i < aNumber; i++) sl@0: Log(_L(" ")); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Close the log. sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::CloseLogFile() sl@0: { sl@0: // add the htm end sl@0: WriteFormat(_L("")); sl@0: sl@0: iClientSession.CloseLog(); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Set log severity. sl@0: * sl@0: * @param "TInt aSeverity" sl@0: * The required severity sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::SetSeverity(TInt aSeverity) sl@0: { sl@0: iSeverity = aSeverity; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Get log severity. sl@0: * sl@0: * @return "TInt" sl@0: * The current severity sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C TInt CLog::Severity() const sl@0: { sl@0: return iSeverity; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Get log status from this logger's client session. sl@0: * sl@0: * @return "TInt" sl@0: * The current log status (a bitmask of TTestFrameworkLogMode) sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C TInt CLog::LogStatus() sl@0: { sl@0: return iClientSession.LogStatus(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: * sl@0: * Write formatted output to the log. sl@0: * sl@0: * @param "TRefByValue aFmt" sl@0: * Printf-style format. sl@0: * sl@0: * @param "..." sl@0: * Variable print parameters sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::WriteFormat(TRefByValue aFmt, ...) sl@0: { sl@0: sl@0: // file / port logging not enabled sl@0: if (!(iLogStatus & ELogToFile)) sl@0: if (!(iLogStatus & ELogToPort)) sl@0: return; sl@0: sl@0: VA_LIST aList; sl@0: VA_START(aList, aFmt); sl@0: sl@0: TIntegrationTestLog16Overflow overflow16; sl@0: sl@0: TUint16* dataBufPtr = (TUint16*)(iDataBuf.Ptr()); sl@0: TPtr16 lineBuf(dataBufPtr, 0, KMaxLogLineLength); sl@0: lineBuf.Fill('\0', KMaxLogLineLength); sl@0: sl@0: // get the current time and date sl@0: TTime now; sl@0: now.HomeTime(); sl@0: TDateTime dateTime = now.DateTime() ; sl@0: sl@0: // add the current time and date sl@0: lineBuf.Format(_L("%02d/%02d/%04d\t%02d:%02d:%02d:%03d\t"), sl@0: dateTime.Day()+1, sl@0: dateTime.Month()+1, sl@0: dateTime.Year(), sl@0: dateTime.Hour(), sl@0: dateTime.Minute(), sl@0: dateTime.Second(), sl@0: (dateTime.MicroSecond() / 1000)); sl@0: sl@0: // followed by the formatted data sl@0: lineBuf.AppendFormatList(aFmt, aList, &overflow16); sl@0: VA_END(aList); sl@0: sl@0: // send one message - the server will write to both if enabled sl@0: TInt theStatus = 0; sl@0: if (iLogStatus & ELogToFile) sl@0: theStatus |= ELogToFile; sl@0: if (iLogStatus & ELogToPort) sl@0: theStatus |= ELogToPort; sl@0: sl@0: iClientSession.WriteLog(lineBuf, theStatus); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Write output to the console with date/time stamp sl@0: * sl@0: * @param "const TDesC& aBuf" sl@0: * The output. sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C void CLog::WriteLogConsole(const TDesC& aBuf) sl@0: { sl@0: sl@0: // console logging not enabled sl@0: if (!(iLogStatus & ELogConsoleFull)) sl@0: return; sl@0: sl@0: // decode formatted data for display on console sl@0: TUint16* dataBufPtr = (TUint16*)(iDataBuf.Ptr()); sl@0: TPtr16 lineBuf(dataBufPtr, 0, KMaxLogLineLength); sl@0: lineBuf.Fill('\0', KMaxLogLineLength); sl@0: sl@0: // get the current time and date sl@0: TTime now; sl@0: now.HomeTime(); sl@0: TDateTime dateTime = now.DateTime() ; sl@0: sl@0: // add the current time and date sl@0: lineBuf.Format(_L("%02d/%02d/%04d\t%02d:%02d:%02d:%03d\t%S"), sl@0: dateTime.Day()+1, sl@0: dateTime.Month()+1, sl@0: dateTime.Year(), sl@0: dateTime.Hour(), sl@0: dateTime.Minute(), sl@0: dateTime.Second(), sl@0: (dateTime.MicroSecond() / 1000), sl@0: &aBuf); sl@0: sl@0: iClientSession.WriteLog(lineBuf, ELogToConsole); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * This function is used to avoid a panic if format text overflows sl@0: * the internal buffer. sl@0: * sl@0: * @param "TDes16&" sl@0: * the overflowing string sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: void TIntegrationTestLog16Overflow::Overflow(TDes16& aDes) sl@0: { sl@0: aDes = _L("*** ERROR : line too long, cannot log ***"); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Check a severity value is valid. sl@0: * sl@0: * @param "TInt aSev" sl@0: * The value to check. sl@0: * sl@0: * @return "TBool" sl@0: * Valid (ETrue) or not (EFalse). sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C TBool LogSeverity::IsValid(TInt aSev) sl@0: { sl@0: return ((aSev & ~(ESevrAll)) == 0); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Check a severity value is active sl@0: * sl@0: * @param "TInt aThisSev" sl@0: * The value to check. sl@0: * sl@0: * @param "TInt aGlobalSev" sl@0: * The value to check against (e.g. global severity value of a log). sl@0: * sl@0: * @return "TBool" sl@0: * Active (ETrue) or not (EFalse). sl@0: * sl@0: * @xxxx sl@0: * sl@0: */ sl@0: EXPORT_C TBool LogSeverity::IsActive(TInt aThisSev, TInt aGlobalSev) sl@0: { sl@0: return ((aThisSev & aGlobalSev) != 0); sl@0: }