LOCAL_C void TestWorkAPIsL(CTestExecuteLogger& aLogger,CConsoleBase*& aConsole) { aConsole->Write(_L("Testing logger.Write(16BitText) \r\n")); aLogger.Write(K16BitText); aConsole->Write(_L("Testing logger.Write(8BitText) \r\n")); aLogger.Write(K8BitText); aConsole->Write(_L("Testing logger.WriteFormat(16BitText) \r\n")); TBuf<20> buf16(K16BitString); aLogger.WriteFormat(K16BitFormatText,16,&buf16); aConsole->Write(_L("Testing logger.WriteFormat(8BitText) \r\n")); TBuf8<20> buf8(K8BitString); aLogger.WriteFormat(K8BitFormatText,8,&buf8); aConsole->Write(_L("Testing logger.LogExtra() \r\n")); aLogger.LogExtra(((TText8*)__FILE__), __LINE__,ESevrInfo,K16BitFormatText,1,&buf16); aConsole->Write(_L("Testing logger.PrintCurrentScriptLine() \r\n")); TBuf<30> output(_L("Testing PrintCurrentScriptLine")) ; aLogger.PrintCurrentScriptLine(output) ; aConsole->Write(_L("Testing logger.LogTestCaseResult() \r\n")); TBuf<30> file(_L("TestExcuteLoggingTest.cpp")); TInt lineNo(68) ; TBuf<20> testCsNm(_L("TestCaseSomething")); aLogger.LogTestCaseResult(file, lineNo, ESevrInfo, KTEFEndTestCaseCommand, testCsNm); aConsole->Write(_L("Testing logger.LogResult() \r\n")); TBuf<30> panicStringbuf(_L("Panic string")) ; TBuf<30> fileRes(_L("TestExcuteLoggingTest.cpp")); TInt lineNum(70) ; TInt severity(RFileFlogger::ESevrHigh) ; aLogger.LogResult(EPass,panicStringbuf,lineNum,KTEFRunTestStepCommand,fileRes,RFileFlogger::ESevrHigh); }
void FdOutput::log(const char* channelName, LogLevel level, const char* msg, time_t time) { char timeStamp[32]; tm currentTime; currentTime = _useUTC ? *gmtime(&time) : *localtime(&time); const char *color = NULL; if ( _colorize ) { sprintf(timeStamp, "%s%02i:%02i:%02i%s ", kGreenColor, currentTime.tm_hour, currentTime.tm_min, currentTime.tm_sec, kNormalColor); switch(level) { case LL_CRITICAL: case LL_ERROR: color = kRedColor; break; case LL_WARNING: color = kYellowColor; break; case LL_NOTICE: case LL_INFO: case LL_DEBUG: default: break; } } else { sprintf(timeStamp, "%02i:%02i:%02i ", currentTime.tm_hour, currentTime.tm_min, currentTime.tm_sec); } std::ostringstream ss; ss << timeStamp; ss << '[' << channelName; if ( likely(_logComponent) ) ss << "/" << component(); ss << "] "; if ( unlikely(_logContext) ) ss << "(" << fileName() << ':' << lineNum() << ") "; #ifndef _WIN32 // THREAD ID /* char tid[16] = ""; snprintf(tid,15,"%lu",pthread_self()); ss << "[tid:" << tid << "] "; */ #endif if( color ) ss << color; ss << msg; if ( color ) ss << kNormalColor; ss << std::endl; std::string out = ss.str(); ssize_t len = write(_fdOut, out.c_str(), out.length()); if ( len == -1 ) {} }