os/mm/mmtestenv/mmtestfw/Source/TestFrameworkClient/Log.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmtestenv/mmtestfw/Source/TestFrameworkClient/Log.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,852 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Client / server logging for Test Framework
    1.18 +// NOTE : does NOT include secure API changes in EKA2
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +
    1.23 +// Test system includes
    1.24 +#include <testframework.h>
    1.25 +
    1.26 +// do not export if Unit Testing
    1.27 +#if defined (__TSU_TESTFRAMEWORK__)
    1.28 +#undef EXPORT_C
    1.29 +#define EXPORT_C
    1.30 +#endif
    1.31 +
    1.32 +/**
    1.33 + *
    1.34 + * HTML font formatting strings
    1.35 + *
    1.36 + * @xxxx
    1.37 + *
    1.38 + */
    1.39 +_LIT(KResultPass, "<font size=4 color=00AF00>");
    1.40 +_LIT(KResultFail, "<font size=4 color=FF0000>");
    1.41 +_LIT(KResultInconclusive, "<font size=4 color=0000FF>");
    1.42 +_LIT(KResultUndefined, "<font size=4 color=FF00FF>");
    1.43 +_LIT(KResultEnd, "</font>");
    1.44 +_LIT(KResultNonHtml, "");
    1.45 +
    1.46 +_LIT(KResultKnownFailure, "<font size=4 color=008080>"); //A new TVerdict for a known failed test
    1.47 +
    1.48 +// logging macro used only for verdicts - not for external use
    1.49 +#define VER_PRINTF(r1, r2, r3)		LogExtra(__FILE8__, __LINE__, ESevrVer, _L("%S%S%S\n"), (r1), (r2), (r3)) 
    1.50 +
    1.51 +/**
    1.52 + *
    1.53 + * Static constructor for CLog.
    1.54 + *
    1.55 + *
    1.56 + * @return	"CLog*"
    1.57 + *			The constructed CLog
    1.58 + *
    1.59 + * @xxxx
    1.60 + *
    1.61 + */
    1.62 +EXPORT_C CLog* CLog::NewL()
    1.63 +	{
    1.64 +	CLog* self = new(ELeave) CLog;
    1.65 +	self->Construct();
    1.66 +	return self;
    1.67 +	}
    1.68 +
    1.69 +/**
    1.70 + *
    1.71 + * Static NewLC constructor for CLog.
    1.72 + *
    1.73 + *
    1.74 + * @return	"CLog*"
    1.75 + *			The constructed CLog
    1.76 + *
    1.77 + * @xxxx
    1.78 + *
    1.79 + */
    1.80 +EXPORT_C CLog* CLog::NewLC()
    1.81 +	{
    1.82 +	CLog* self = new(ELeave) CLog;
    1.83 +	CleanupStack::PushL(self);
    1.84 +	self->Construct();
    1.85 +	return self;
    1.86 +	}
    1.87 +
    1.88 +/**
    1.89 + *
    1.90 + * Second-phase constructor for CLog.
    1.91 + *
    1.92 + * @xxxx
    1.93 + *
    1.94 + */
    1.95 +EXPORT_C void CLog::Construct()
    1.96 +	{
    1.97 +	iLogStatus = 0;		// no outputs enabled yet
    1.98 +	iSeverity = ESevrAll;
    1.99 +	//Do we need to put information about source file & #line?
   1.100 +	//Default is yes.
   1.101 +	iLogFlags = ELogPutSrcInfo | ELogHtmlMode;
   1.102 +	}
   1.103 +
   1.104 +/**
   1.105 + *
   1.106 + * Destructor for CLog.
   1.107 + *
   1.108 + * @xxxx
   1.109 + *
   1.110 + */
   1.111 +EXPORT_C CLog::~CLog()
   1.112 +	{
   1.113 +	// tell server to close logs here
   1.114 +	iClientSession.Close();
   1.115 +	}
   1.116 +
   1.117 +/**
   1.118 + *
   1.119 + * Open a new test log.
   1.120 + *
   1.121 + * @param	"const TDesC& aLogName"
   1.122 + *			Log file or console name
   1.123 + *
   1.124 + * @param	"TInt aLogMode"
   1.125 + *			Log modes (a bitmask of TTestFrameworkLogMode).
   1.126 + *
   1.127 + * @xxxx
   1.128 + *
   1.129 + */
   1.130 +EXPORT_C void CLog::OpenLogFileL(const TDesC& aLogName, TInt aLogMode)
   1.131 +	{
   1.132 +	User::LeaveIfError(iClientSession.Connect());
   1.133 +
   1.134 +	iClientSession.OpenLog(aLogName, aLogMode);
   1.135 +	// get and store the log status - this will determine whether we
   1.136 +	// e.g. do any formatting for file output
   1.137 +	iLogStatus = iClientSession.LogStatus();
   1.138 +	}
   1.139 +
   1.140 +/**
   1.141 + *
   1.142 + * Open an existing test log.
   1.143 + *
   1.144 + * @xxxx
   1.145 + *
   1.146 + */
   1.147 +EXPORT_C void CLog::OpenLogFileL()
   1.148 +	{
   1.149 +	User::LeaveIfError(iClientSession.Connect());
   1.150 +	iLogStatus = iClientSession.LogStatus();
   1.151 +	}
   1.152 +
   1.153 +/**
   1.154 + *
   1.155 + * Set put source info (i.e. traceable logging).
   1.156 + *
   1.157 + * @param	"TBool aPutSrcInfo"
   1.158 + *			Put source info on or off.
   1.159 + *
   1.160 + * @xxxx
   1.161 + *
   1.162 + */
   1.163 +EXPORT_C void CLog::SetPutSrcInfo(TBool aPutSrcInfo)
   1.164 +	{
   1.165 +	if(aPutSrcInfo)
   1.166 +		iLogFlags |= ELogPutSrcInfo;
   1.167 +	else
   1.168 +		iLogFlags &= ~ELogPutSrcInfo;
   1.169 +	}
   1.170 +	
   1.171 +/**
   1.172 + *
   1.173 + * Set HTML logging mode.
   1.174 + *
   1.175 + * @param	"TBool aArg"
   1.176 + *			HTML mode on or off.
   1.177 + *
   1.178 + * @xxxx
   1.179 + *
   1.180 + */
   1.181 +EXPORT_C void CLog::SetHtmlLogMode(TBool aArg)
   1.182 +	{
   1.183 +	if(aArg)
   1.184 +		iLogFlags |= ELogHtmlMode;
   1.185 +	else
   1.186 +		iLogFlags &= ~ELogHtmlMode;
   1.187 +	}
   1.188 + 
   1.189 +/**
   1.190 + *
   1.191 + * Get HTML logging mode.
   1.192 + *
   1.193 + * @return	"TBool"
   1.194 + *			HTML mode on or off.
   1.195 + *
   1.196 + * @xxxx
   1.197 + *
   1.198 + */
   1.199 +EXPORT_C TBool CLog::HtmlLogMode() const
   1.200 +	{
   1.201 +	return ((iLogFlags & ELogHtmlMode) != 0);
   1.202 +	}
   1.203 +
   1.204 +
   1.205 +/**
   1.206 + *
   1.207 + * General logging function.
   1.208 + *
   1.209 + * @param	"TRefByValue<const TDesC16> aFmt"
   1.210 + *			Printf-style format.
   1.211 + *
   1.212 + * @param	"..."
   1.213 + *			Variable print parameters
   1.214 + *
   1.215 + * @xxxx
   1.216 + *
   1.217 + */
   1.218 +EXPORT_C void CLog::Log(TRefByValue<const TDesC16> aFmt, ...)
   1.219 +	{
   1.220 +    VA_LIST aList;
   1.221 +	VA_START(aList, aFmt);
   1.222 +
   1.223 +	TIntegrationTestLog16Overflow overflow16;
   1.224 +
   1.225 +	// decode formatted data for display on console
   1.226 +	TBuf<KMaxLogLineLength> lineBuf;
   1.227 +	lineBuf = KNullDesC;
   1.228 +	lineBuf.AppendFormatList(aFmt, aList, &overflow16);
   1.229 +
   1.230 +	// write to the console
   1.231 +	if(iLogStatus & ELogConsoleFull)
   1.232 +		iClientSession.WriteLog(lineBuf, ELogToConsole);
   1.233 +
   1.234 +	// write to log file
   1.235 +	WriteFormat(_L("%S\n"), &lineBuf);
   1.236 +
   1.237 +	VA_END(aList); 
   1.238 +	}
   1.239 +
   1.240 +/**
   1.241 + *
   1.242 + * General logging function with severity.
   1.243 + *
   1.244 + * @param	"TInt aSeverity"
   1.245 + *			Severity level required to log
   1.246 + *
   1.247 + * @param	"TRefByValue<const TDesC16> aFmt"
   1.248 + *			Printf-style format.
   1.249 + *
   1.250 + * @param	"..."
   1.251 + *			Variable print parameters
   1.252 + *
   1.253 + * @xxxx
   1.254 + *
   1.255 + */
   1.256 +EXPORT_C void CLog::Log(TInt aSeverity, TRefByValue<const TDesC16> aFmt, ...)
   1.257 +	{
   1.258 +    VA_LIST aList;
   1.259 +	VA_START(aList, aFmt);
   1.260 +
   1.261 +	if(LogSeverity::IsActive(aSeverity, Severity()))
   1.262 +		{
   1.263 +		Log(aFmt, aList);
   1.264 +		}
   1.265 +
   1.266 +	VA_END(aList); 
   1.267 +	}
   1.268 +
   1.269 +/**
   1.270 + *
   1.271 + * General logging function.
   1.272 + *
   1.273 + * @param	"TRefByValue<const TDesC16> aFmt"
   1.274 + *			Printf-style format.
   1.275 + *
   1.276 + * @param	"VA_LIST aList"
   1.277 + *			Variable print parameters
   1.278 + *
   1.279 + * @xxxx
   1.280 + *
   1.281 + */
   1.282 +EXPORT_C void CLog::Log(TRefByValue<const TDesC16> aFmt, VA_LIST aList)
   1.283 +	{
   1.284 +	// decode formatted data for display on console
   1.285 +	TBuf<KMaxLogLineLength> lineBuf;
   1.286 +	TIntegrationTestLog16Overflow overflow16;
   1.287 +
   1.288 +	lineBuf = KNullDesC;
   1.289 +	lineBuf.AppendFormatList(aFmt, aList, &overflow16);
   1.290 +
   1.291 +	// write to log file
   1.292 +	WriteFormat(_L("%S\n"),&lineBuf);
   1.293 +
   1.294 +	// write to the console
   1.295 +	if(iLogStatus & ELogConsoleFull)
   1.296 +		iClientSession.WriteLog(lineBuf, ELogToConsole);
   1.297 +
   1.298 +	}
   1.299 +
   1.300 +/**
   1.301 + *
   1.302 + * Traceable logging function
   1.303 + *
   1.304 + * Should be used for macros only
   1.305 + *
   1.306 + * @param	"const TText8* aFile"
   1.307 + *			Source code file name
   1.308 + *
   1.309 + * @param	"TInt aLine"
   1.310 + *			Source code line
   1.311 + *
   1.312 + * @param	"TInt aSeverity"
   1.313 + *			Severity level required to log
   1.314 + *
   1.315 + * @param	"TRefByValue<const TDesC16> aFmt"
   1.316 + *			Printf-style format.
   1.317 + *
   1.318 + * @param	"VA_LIST aList"
   1.319 + *			Variable print parameters
   1.320 + *
   1.321 + * @xxxx
   1.322 + *
   1.323 + */
   1.324 +#ifdef EXCLUDE_FOR_UNITTEST
   1.325 +EXPORT_C void CLog::LogExtra(const TText8* /*aFile*/, TInt /*aLine*/, TInt /*aSeverity*/,
   1.326 +							 TRefByValue<const TDesC16> /*aFmt*/, VA_LIST /*aList*/)
   1.327 +	{
   1.328 +	}
   1.329 +#else
   1.330 +EXPORT_C void CLog::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,
   1.331 +							 TRefByValue<const TDesC16> aFmt, VA_LIST aList)
   1.332 +	{
   1.333 +	if(LogSeverity::IsActive(aSeverity, Severity()))
   1.334 +		{
   1.335 +
   1.336 +		TIntegrationTestLog16Overflow overflow16;
   1.337 +
   1.338 +		// decode formatted data for display on console
   1.339 +		TBuf<KMaxLogLineLength> lineBuf;
   1.340 +
   1.341 +		lineBuf = KNullDesC;
   1.342 +		lineBuf.AppendFormatList(aFmt, aList, &overflow16);
   1.343 +
   1.344 +		// write to the console
   1.345 +		if(iLogStatus & ELogConsoleFull)
   1.346 +			WriteLogConsole(lineBuf);
   1.347 +
   1.348 +		// log severity
   1.349 +		TBuf<1> charSevr;
   1.350 +		switch(aSeverity)
   1.351 +			{
   1.352 +			case ESevrVer:
   1.353 +				charSevr = _L("V");
   1.354 +				break;
   1.355 +			case ESevrErr:
   1.356 +				charSevr = _L("E");
   1.357 +				break;
   1.358 +			case ESevrWarn:
   1.359 +				charSevr = _L("W");
   1.360 +				break;
   1.361 +			case ESevrInfo:
   1.362 +			default:
   1.363 +				charSevr = _L("I");
   1.364 +				break;
   1.365 +			}
   1.366 +
   1.367 +		// Do we need to put information about source file & #line?
   1.368 +		if(iLogFlags & ELogPutSrcInfo)
   1.369 +			{		// Braces used to scope lifetime of TBuf objects
   1.370 +			TPtrC8 fileName8(aFile);
   1.371 +			TBuf<256> fileName;
   1.372 +			TParse printFileName;
   1.373 +			fileName.Copy(fileName8);  // TText8->TBuf16
   1.374 +			// We don't need full file name.
   1.375 +			printFileName.Set(fileName, NULL, NULL) ;
   1.376 +			fileName.Copy(printFileName.NameAndExt()) ;
   1.377 +			// write to log file
   1.378 +			WriteFormat(_L("%S\t%S\t%d\t%S\n"), &charSevr, &fileName, aLine, &lineBuf);
   1.379 +			}
   1.380 +		else
   1.381 +			{
   1.382 +			// write to log file
   1.383 +			WriteFormat(_L("%S\t%S\n"), &charSevr, &lineBuf);
   1.384 +			}
   1.385 +		}
   1.386 +	}
   1.387 +#endif // EXCLUDE_FOR_UNITTEST
   1.388 +
   1.389 +/**
   1.390 + *
   1.391 + * Traceable logging function with variable param list.
   1.392 + *
   1.393 + * Should be used for macros only
   1.394 + *
   1.395 + * @param	"const TText8* aFile"
   1.396 + *			Source code file name
   1.397 + *
   1.398 + * @param	"TInt aLine"
   1.399 + *			Source code line
   1.400 + *
   1.401 + * @param	"TInt aSeverity"
   1.402 + *			Severity level required to log
   1.403 + *
   1.404 + * @param	"TRefByValue<const TDesC16> aFmt"
   1.405 + *			Printf-style format.
   1.406 + *
   1.407 + * @param	"..."
   1.408 + *			Variable print parameters
   1.409 + *
   1.410 + * @xxxx
   1.411 + *
   1.412 + */
   1.413 +EXPORT_C void CLog::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,
   1.414 +		TRefByValue<const TDesC16> aFmt,...)
   1.415 +	{
   1.416 +	VA_LIST aList;
   1.417 +	VA_START(aList, aFmt);
   1.418 +	LogExtra(aFile, aLine, aSeverity, aFmt, aList);
   1.419 +	VA_END(aList); 
   1.420 +	}
   1.421 +
   1.422 +
   1.423 +/**
   1.424 + *
   1.425 + * Write a test result highlighted to the log.
   1.426 + *
   1.427 + * @param	"TVerdict aVerdict"
   1.428 + *			The test verdict.
   1.429 + *
   1.430 + * @param	"TRefByValue<const TDesC16> aFmt"
   1.431 + *			Printf-style format.
   1.432 + *
   1.433 + * @param	"..."
   1.434 + *			Variable print parameters
   1.435 + *
   1.436 + * @xxxx
   1.437 + *
   1.438 + */
   1.439 +EXPORT_C void CLog::LogResult(TVerdict aVerdict, TRefByValue<const TDesC16> aFmt, ...)
   1.440 +	{
   1.441 +    VA_LIST aList;
   1.442 +	VA_START(aList, aFmt);
   1.443 +
   1.444 +	TIntegrationTestLog16Overflow iOverflow16;
   1.445 +
   1.446 +	// decode formatted data for display on console
   1.447 +	TBuf <KMaxLogLineLength> lineBuf;
   1.448 +	lineBuf.AppendFormatList(aFmt, aList, &iOverflow16);
   1.449 +
   1.450 +	// write to the console
   1.451 +	iClientSession.WriteLog(lineBuf, ELogToConsole);
   1.452 +
   1.453 +	// write to log file
   1.454 +	if(iLogFlags & ELogHtmlMode)
   1.455 +		{ 
   1.456 +		switch(aVerdict)
   1.457 +			{
   1.458 +		case EPass:
   1.459 +			VER_PRINTF(&KResultPass(), &lineBuf, &KResultEnd());
   1.460 +			break;
   1.461 +		case EFail:
   1.462 +			VER_PRINTF(&KResultFail(), &lineBuf, &KResultEnd());
   1.463 +			break;
   1.464 +		case EInconclusive:
   1.465 +		case ETestSuiteError:
   1.466 +		case EAbort:
   1.467 +			VER_PRINTF(&KResultInconclusive(), &lineBuf, &KResultEnd());
   1.468 +			break;
   1.469 +		case EKnownFailure:	//A new TVerdict for a known failed test
   1.470 +			VER_PRINTF(&KResultKnownFailure(), &lineBuf, &KResultEnd());
   1.471 +			break;
   1.472 +
   1.473 +		default: // undefined
   1.474 +			VER_PRINTF(&KResultUndefined(), &lineBuf, &KResultEnd());
   1.475 +			break;
   1.476 +			}
   1.477 +		}
   1.478 +	else
   1.479 +		{
   1.480 +			VER_PRINTF(&KResultNonHtml(), &lineBuf, &KResultNonHtml());
   1.481 +		}	
   1.482 +	VA_END(aList); 
   1.483 +	}
   1.484 +
   1.485 +/**
   1.486 + *
   1.487 + * Make a readable string out of an EPOC error code.
   1.488 + *
   1.489 + * @param	"TInt aError"
   1.490 + *			The error code
   1.491 + *
   1.492 + * @return	"TPtrC"
   1.493 + *			The error code as a readable string
   1.494 + *
   1.495 + * @xxxx
   1.496 + *
   1.497 + */
   1.498 +EXPORT_C TPtrC CLog::EpocErrorToText(TInt aError)
   1.499 +	{
   1.500 +	switch (aError)
   1.501 +		{
   1.502 +	case KErrNone:
   1.503 +		return _L("KErrNone");
   1.504 +	case KErrNotFound:
   1.505 +		return _L("KErrNotFound");
   1.506 +	case KErrGeneral:
   1.507 +		return _L("KErrGeneral");
   1.508 +	case KErrCancel:
   1.509 +		return _L("KErrCancel");
   1.510 +	case KErrNoMemory:
   1.511 +		return _L("KErrNoMemory");
   1.512 +	case KErrNotSupported:
   1.513 +		return _L("KErrNotSupported");
   1.514 +	case KErrArgument:
   1.515 +		return _L("KErrArgument");
   1.516 +	case KErrTotalLossOfPrecision:
   1.517 +		return _L("KErrTotalLossOfPrecision");
   1.518 +	case KErrBadHandle:
   1.519 +		return _L("KErrBadHandle");
   1.520 +	case KErrOverflow:
   1.521 +		return _L("KErrOverflow");
   1.522 +	case KErrUnderflow:
   1.523 +		return _L("KErrUnderflow");
   1.524 +	case KErrAlreadyExists:
   1.525 +		return _L("KErrAlreadyExists");
   1.526 +	case KErrPathNotFound:
   1.527 +		return _L("KErrPathNotFound");
   1.528 +	case KErrDied:
   1.529 +		return _L("KErrDied");
   1.530 +	case KErrInUse:
   1.531 +		return _L("KErrInUse");
   1.532 +	case KErrServerTerminated:
   1.533 +		return _L("KErrServerTerminated");
   1.534 +	case KErrServerBusy:
   1.535 +		return _L("KErrServerBusy");
   1.536 +	case KErrCompletion:
   1.537 +		return _L("KErrCompletion");
   1.538 +	case KErrNotReady:
   1.539 +		return _L("KErrNotReady");
   1.540 +	case KErrUnknown:
   1.541 +		return _L("KErrUnknown");
   1.542 +	case KErrCorrupt:
   1.543 +		return _L("KErrCorrupt");
   1.544 +	case KErrAccessDenied:
   1.545 +		return _L("KErrAccessDenied");
   1.546 +	case KErrLocked:
   1.547 +		return _L("KErrLocked");
   1.548 +	case KErrWrite:
   1.549 +		return _L("KErrWrite");
   1.550 +	case KErrDisMounted:
   1.551 +		return _L("KErrDisMounted");
   1.552 +	case KErrEof:
   1.553 +		return _L("KErrEof");
   1.554 +	case KErrDiskFull:
   1.555 +		return _L("KErrDiskFull");
   1.556 +	case KErrBadDriver:
   1.557 +		return _L("KErrBadDriver");
   1.558 +	case KErrBadName:
   1.559 +		return _L("KErrBadName");
   1.560 +	case KErrCommsLineFail:
   1.561 +		return _L("KErrCommsLineFail");
   1.562 +	case KErrCommsFrame:
   1.563 +		return _L("KErrCommsFrame");
   1.564 +	case KErrCommsOverrun:
   1.565 +		return _L("KErrCommsOverrun");
   1.566 +	case KErrCommsParity:
   1.567 +		return _L("KErrCommsParity");
   1.568 +	case KErrTimedOut:
   1.569 +		return _L("KErrTimedOut");
   1.570 +	case KErrCouldNotConnect:
   1.571 +		return _L("KErrCouldNotConnect");
   1.572 +	case KErrCouldNotDisconnect:
   1.573 +		return _L("KErrCouldNotDisconnect");
   1.574 +	case KErrDisconnected:
   1.575 +		return _L("KErrDisconnected");
   1.576 +	case KErrBadLibraryEntryPoint:
   1.577 +		return _L("KErrBadLibraryEntryPoint");
   1.578 +	case KErrBadDescriptor:
   1.579 +		return _L("KErrBadDescriptor");
   1.580 +	case KErrAbort:
   1.581 +		return _L("KErrAbort");
   1.582 +	case KErrTooBig:
   1.583 +		return _L("KErrTooBig");
   1.584 +	default:
   1.585 +		return _L("Unknown");
   1.586 +		} // end switch
   1.587 +	}
   1.588 +
   1.589 +
   1.590 +/**
   1.591 + *
   1.592 + * Make a readable string out of a test verdict.
   1.593 + *
   1.594 + * @param	"TVerdict aTestVerdict"
   1.595 + *			The test verdict
   1.596 + *
   1.597 + * @return	"TPtrC"
   1.598 + *			The test verdict as a readable string
   1.599 + *
   1.600 + * @xxxx
   1.601 + *
   1.602 + */
   1.603 +EXPORT_C TPtrC CLog::TestResultText(TVerdict aTestVerdict)
   1.604 +	{
   1.605 +	switch (aTestVerdict)
   1.606 +		{
   1.607 +	case EPass:
   1.608 +		return _L("PASS");
   1.609 +	case EFail:
   1.610 +		return _L("FAIL");
   1.611 +	case EInconclusive:
   1.612 +		return _L("INCONCLUSIVE");
   1.613 +	case ETestSuiteError:
   1.614 +		return _L("TEST_SUITE_ERROR");
   1.615 +	case EAbort:
   1.616 +		return _L("ABORT");
   1.617 +	case EKnownFailure: //A new TVerdict for a known failed test
   1.618 +		return _L("KNOWN_Failure"); //using lower case in 'Failure' can remove the confusion on 'savres2html.bat' making test summary
   1.619 +	default:
   1.620 +		return _L("undefined");
   1.621 +
   1.622 +		}
   1.623 +	}
   1.624 +
   1.625 +/**
   1.626 + *
   1.627 + * Write blank lines to the log.
   1.628 + *
   1.629 + * @param	"TInt number"
   1.630 + *			Number of lines to write
   1.631 + *
   1.632 + * @xxxx
   1.633 + *
   1.634 + */
   1.635 +EXPORT_C void CLog::LogBlankLine(TInt aNumber)
   1.636 +	{
   1.637 +	for (TInt i = 0; i < aNumber; i++)
   1.638 +		Log(_L(" "));
   1.639 +	}
   1.640 +
   1.641 +/**
   1.642 + *
   1.643 + * Close the log.
   1.644 + *
   1.645 + * @xxxx
   1.646 + *
   1.647 + */
   1.648 +EXPORT_C void CLog::CloseLogFile()
   1.649 +	{
   1.650 +	// add the htm end
   1.651 +	WriteFormat(_L("</end>"));
   1.652 +	
   1.653 +	iClientSession.CloseLog();
   1.654 +	}
   1.655 +
   1.656 +/**
   1.657 + *
   1.658 + * Set log severity.
   1.659 + *
   1.660 + * @param	"TInt aSeverity"
   1.661 + *			The required severity
   1.662 + *
   1.663 + * @xxxx
   1.664 + *
   1.665 + */
   1.666 +EXPORT_C void CLog::SetSeverity(TInt aSeverity)
   1.667 +{
   1.668 +	iSeverity = aSeverity;
   1.669 +}
   1.670 +
   1.671 +/**
   1.672 + *
   1.673 + * Get log severity.
   1.674 + *
   1.675 + * @return	"TInt"
   1.676 + *			The current severity
   1.677 + *
   1.678 + * @xxxx
   1.679 + *
   1.680 + */
   1.681 +EXPORT_C TInt CLog::Severity() const
   1.682 +{
   1.683 +	return iSeverity;
   1.684 +}
   1.685 +
   1.686 +/**
   1.687 + *
   1.688 + * Get log status from this logger's client session.
   1.689 + *
   1.690 + * @return	"TInt"
   1.691 + *			The current log status (a bitmask of TTestFrameworkLogMode)
   1.692 + *
   1.693 + * @xxxx
   1.694 + *
   1.695 + */
   1.696 +EXPORT_C TInt CLog::LogStatus()
   1.697 +	{
   1.698 +	return iClientSession.LogStatus();
   1.699 +	}
   1.700 +
   1.701 +
   1.702 +/**
   1.703 + *
   1.704 + * Write formatted output to the log.
   1.705 + *
   1.706 + * @param	"TRefByValue<const TDesC16> aFmt"
   1.707 + *			Printf-style format.
   1.708 + *
   1.709 + * @param	"..."
   1.710 + *			Variable print parameters
   1.711 + *
   1.712 + * @xxxx
   1.713 + *
   1.714 + */
   1.715 +EXPORT_C void CLog::WriteFormat(TRefByValue<const TDesC16> aFmt, ...)
   1.716 +	{
   1.717 +
   1.718 +	// file / port logging not enabled
   1.719 +	if (!(iLogStatus & ELogToFile))
   1.720 +		if (!(iLogStatus & ELogToPort))
   1.721 +			return;
   1.722 +
   1.723 +    VA_LIST aList;
   1.724 +	VA_START(aList, aFmt);
   1.725 +
   1.726 +	TIntegrationTestLog16Overflow overflow16;
   1.727 +
   1.728 +	TUint16* dataBufPtr = (TUint16*)(iDataBuf.Ptr());
   1.729 +	TPtr16 lineBuf(dataBufPtr, 0, KMaxLogLineLength);
   1.730 +	lineBuf.Fill('\0', KMaxLogLineLength);
   1.731 +
   1.732 +	// get the current time and date
   1.733 +	TTime now;
   1.734 +	now.HomeTime();
   1.735 +	TDateTime dateTime = now.DateTime() ;
   1.736 +
   1.737 +	// add the current time and date 
   1.738 +	lineBuf.Format(_L("%02d/%02d/%04d\t%02d:%02d:%02d:%03d\t"),
   1.739 +		dateTime.Day()+1,
   1.740 +		dateTime.Month()+1,
   1.741 +		dateTime.Year(),
   1.742 +		dateTime.Hour(),
   1.743 +		dateTime.Minute(),
   1.744 +		dateTime.Second(),
   1.745 +		(dateTime.MicroSecond() / 1000)); 
   1.746 +
   1.747 +	// followed by the formatted data
   1.748 +	lineBuf.AppendFormatList(aFmt, aList, &overflow16);
   1.749 +	VA_END(aList); 
   1.750 +
   1.751 +	// send one message - the server will write to both if enabled
   1.752 +	TInt theStatus = 0;
   1.753 +	if (iLogStatus & ELogToFile)
   1.754 +		theStatus |= ELogToFile;
   1.755 +	if (iLogStatus & ELogToPort)
   1.756 +		theStatus |= ELogToPort;
   1.757 +
   1.758 +	iClientSession.WriteLog(lineBuf, theStatus);
   1.759 +	}
   1.760 +
   1.761 +/**
   1.762 + *
   1.763 + * Write output to the console with date/time stamp
   1.764 + *
   1.765 + * @param	"const TDesC& aBuf"
   1.766 + *			The output.
   1.767 + *
   1.768 + * @xxxx
   1.769 + *
   1.770 + */
   1.771 +EXPORT_C void CLog::WriteLogConsole(const TDesC& aBuf)
   1.772 +	{
   1.773 +
   1.774 +	// console logging not enabled
   1.775 +	if (!(iLogStatus & ELogConsoleFull))
   1.776 +		return;
   1.777 +
   1.778 +	// decode formatted data for display on console
   1.779 +	TUint16* dataBufPtr = (TUint16*)(iDataBuf.Ptr());
   1.780 +	TPtr16 lineBuf(dataBufPtr, 0, KMaxLogLineLength);
   1.781 +	lineBuf.Fill('\0', KMaxLogLineLength);
   1.782 +
   1.783 +	// get the current time and date
   1.784 +	TTime now;
   1.785 +	now.HomeTime();
   1.786 +	TDateTime dateTime = now.DateTime() ;
   1.787 +
   1.788 +	// add the current time and date 
   1.789 +	lineBuf.Format(_L("%02d/%02d/%04d\t%02d:%02d:%02d:%03d\t%S"),
   1.790 +		dateTime.Day()+1,
   1.791 +		dateTime.Month()+1,
   1.792 +		dateTime.Year(),
   1.793 +		dateTime.Hour(),
   1.794 +		dateTime.Minute(),
   1.795 +		dateTime.Second(),
   1.796 +		(dateTime.MicroSecond() / 1000),
   1.797 +		&aBuf); 
   1.798 +
   1.799 +	iClientSession.WriteLog(lineBuf, ELogToConsole);
   1.800 +	}
   1.801 +
   1.802 +/**
   1.803 + *
   1.804 + * This function is used to avoid a panic if format text overflows 
   1.805 + * the internal buffer.
   1.806 + *
   1.807 + * @param "TDes16&"
   1.808 + *		  the overflowing string
   1.809 + *
   1.810 + * @xxxx
   1.811 + *
   1.812 + */
   1.813 +void TIntegrationTestLog16Overflow::Overflow(TDes16& aDes)
   1.814 +	{
   1.815 +	aDes = _L("*** ERROR : line too long, cannot log ***");
   1.816 +	}
   1.817 +
   1.818 +/**
   1.819 + *
   1.820 + * Check a severity value is valid.
   1.821 + *
   1.822 + * @param "TInt aSev"
   1.823 + *		  The value to check.
   1.824 + *
   1.825 + * @return "TBool"
   1.826 + *			Valid (ETrue) or not (EFalse).
   1.827 + *
   1.828 + * @xxxx
   1.829 + *
   1.830 + */
   1.831 +EXPORT_C TBool LogSeverity::IsValid(TInt aSev)
   1.832 +	{ 
   1.833 +	return ((aSev & ~(ESevrAll)) == 0);
   1.834 +	}
   1.835 +
   1.836 +/**
   1.837 + *
   1.838 + * Check a severity value is active
   1.839 + *
   1.840 + * @param "TInt aThisSev"
   1.841 + *		  The value to check.
   1.842 + *
   1.843 + * @param "TInt aGlobalSev"
   1.844 + *		  The value to check against (e.g. global severity value of a log).
   1.845 + *
   1.846 + * @return "TBool"
   1.847 + *			Active (ETrue) or not (EFalse).
   1.848 + *
   1.849 + * @xxxx
   1.850 + *
   1.851 + */
   1.852 +EXPORT_C TBool LogSeverity::IsActive(TInt aThisSev, TInt aGlobalSev)
   1.853 +	{ 
   1.854 +	return ((aThisSev & aGlobalSev) != 0);
   1.855 +	}