atslogger.h File Reference

const TLitC< sizeof(L"AtsLogger")/2 > KAtsLogger

const TLitC< sizeof(L"AtsLogger")/2 >KAtsLogger[static]

const TLitC< sizeof(L"NA")/2 > KAtsLoggerNa

const TLitC< sizeof(L"NA")/2 >KAtsLoggerNa[static]

const TLitC< sizeof(L"PASSED")/2 > KAtsLoggerPassed

const TLitC< sizeof(L"PASSED")/2 >KAtsLoggerPassed[static]

const TLitC< sizeof(L"FAILED")/2 > KAtsLoggerFailed

const TLitC< sizeof(L"FAILED")/2 >KAtsLoggerFailed[static]

const TLitC< sizeof(L"SKIPPED")/2 > KAtsLoggerSkipped

const TLitC< sizeof(L"SKIPPED")/2 >KAtsLoggerSkipped[static]

const TLitC< sizeof(L"")/2 > KAtsLoggerEmpty

const TLitC< sizeof(L"")/2 >KAtsLoggerEmpty[static]

const TLitC< sizeof(L"AtsLogger")/2 > KAtsLoggerSemaphore

const TLitC< sizeof(L"AtsLogger")/2 >KAtsLoggerSemaphore[static]

const TLitC< sizeof(L"\\SPD_LOGS\\XML\\")/2 > KAtsLoggerXmlDirectory

const TLitC< sizeof(L"\\SPD_LOGS\\XML\\")/2 >KAtsLoggerXmlDirectory[static]

const TLitC< sizeof(L"\\SPD_LOGS\\RAW\\")/2 > KAtsLoggerRawDirectory

const TLitC< sizeof(L"\\SPD_LOGS\\RAW\\")/2 >KAtsLoggerRawDirectory[static]

const TLitC< sizeof(L".xml")/2 > KAtsLoggerXmlSuffix

const TLitC< sizeof(L".xml")/2 >KAtsLoggerXmlSuffix[static]

const TLitC< sizeof(L".log")/2 > KAtsLoggerRawSuffix

const TLitC< sizeof(L".log")/2 >KAtsLoggerRawSuffix[static]

const TLitC< sizeof(L"<")/2 >KAtsLoggerTagOpen={sizeof(L"<")/2-1, L"<"};const static TLitC< sizeof(L" ")/2 >KAtsLoggerSpace={sizeof(L" ")/2-1, L" "};const static TLitC< sizeof(L"=\"")/2 >KAtsLoggerAttr={sizeof(L"=\"")/2-1, L"=\""};const static TLitC< sizeof(L"\">")/2 >KAtsLoggerAttrClose={sizeof(L"\">")/2-1, L"\">

constTLitC< sizeof(L"<")/2 >KAtsLoggerTagOpen={sizeof(L"<")/2-1, L"<"};const static TLitC< sizeof(L" ")/2 >KAtsLoggerSpace={sizeof(L" ")/2-1, L" "};const static TLitC< sizeof(L"=\"")/2 >KAtsLoggerAttr={sizeof(L"=\"")/2-1, L"=\""};const static TLitC< sizeof(L"\">")/2 >KAtsLoggerAttrClose={sizeof(L"\">")/2-1, L"\">[static]

const TLitC< sizeof(L"> KAtsLoggerTagPost

const TLitC< sizeof(L">KAtsLoggerTagPost[static]

const TLitC< sizeof(L"</")/2 > KAtsLoggerTagClose={sizeof(L"</")/2-1, L"</"};const static TLitC< sizeof(L"\n")/2 > KAtsLoggerLf={sizeof(L"\n")/2-1, L"\n"};const static TLitC< sizeof(L" ")/2 > KAtsLoggerIndent={sizeof(L" ")/2-1, L" "};const static TLitC8< sizeof(" ")> KAtsLoggerIndent8={sizeof(" ")-1," "};const static TLitC< sizeof(L"<!--")/2 > KAtsLoggerCommentOpen={sizeof(L"<!--")/2-1, L"<!--"};const static TLitC< sizeof(L"-->")/2 > KAtsLoggerCommentClose={sizeof(L"-->")/2-1, L"-->"};const static TLitC< sizeof(L"&quot;")/2 > KAtsLoggerQuot={sizeof(L"&quot;")/2-1, L"&quot;"};const static TLitC< sizeof(L"&amp;")/2 > KAtsLoggerAmp={sizeof(L"&amp;")/2-1, L"&amp;"};const static TLitC< sizeof(L"&apos;")/2 > KAtsLoggerApos={sizeof(L"&apos;")/2-1, L"&apos;"};const static TLitC< sizeof(L"&lt;")/2 > KAtsLoggerLt={sizeof(L"&lt;")/2-1, L"&lt;"};const static TLitC< sizeof(L"&gt;")/2 > KAtsLoggerGt={sizeof(L"&gt;")/2-1, L"&gt;"};const static TLitC8< sizeof("&quot;")> KAtsLoggerQuot8={sizeof("&quot;")-1,"&quot;"};const static TLitC8< sizeof("&amp;")> KAtsLoggerAmp8={sizeof("&amp;")-1,"&amp;"};const static TLitC8< sizeof("&apos;")> KAtsLoggerApos8={sizeof("&apos;")-1,"&apos;"};const static TLitC8< sizeof("&lt;")> KAtsLoggerLt8={sizeof("&lt;")-1,"&lt;"};const static TLitC8< sizeof("&gt;")> KAtsLoggerGt8={sizeof("&gt;")-1,"&gt;"};const static TLitC8< sizeof("")> KAtsLoggerEmpty8={sizeof("")-1,""};const static TLitC< sizeof(L"test-report")/2 > KAtsLoggerTagTestReport={sizeof(L"test-report")/2-1, L"test-report"};const static TLitC< sizeof(L"test-batch")/2 > KAtsLoggerTagTestSet={sizeof(L"test-batch")/2-1, L"test-batch"};const static TLitC< sizeof(L"test-case")/2 > KAtsLoggerTagTestCase={sizeof(L"test-case")/2-1, L"test-case"};const static TLitC< sizeof(L"batch-init")/2 > KAtsLoggerTagTestSetInit={sizeof(L"batch-init")/2-1, L"batch-init"};const static TLitC< sizeof(L"description")/2 > KAtsLoggerTagDescription={sizeof(L"description")/2-1, L"description"};const static TLitC< sizeof(L"date")/2 > KAtsLoggerTagDate={sizeof(L"date")/2-1, L"date"};const static TLitC< sizeof(L"factory")/2 > KAtsLoggerTagFactory={sizeof(L"factory")/2-1, L"factory"};const static TLitC< sizeof(L"component")/2 > KAtsLoggerTagComponent={sizeof(L"component")/2-1, L"component"};const static TLitC< sizeof(L"name")/2 > KAtsLoggerTagName={sizeof(L"name")/2-1, L"name"};const static TLitC< sizeof(L"version")/2 > KAtsLoggerTagVersion={sizeof(L"version")/2-1, L"version"};const static TLitC< sizeof(L"batch-result")/2 > KAtsLoggerTagTestSetResult={sizeof(L"batch-result")/2-1, L"batch-result"};const static TLitC< sizeof(L"id")/2 > KAtsLoggerTagId={sizeof(L"id")/2-1, L"id"};const static TLitC< sizeof(L"case-init")/2 > KAtsLoggerTagTestCaseInit={sizeof(L"case-init")/2-1, L"case-init"};const static TLitC< sizeof(L"expected-result")/2 > KAtsLoggerTagExpected={sizeof(L"expected-result")/2-1, L"expected-result"};const static TLitC< sizeof(L"run-time")/2 > KAtsLoggerTagRunTime={sizeof(L"run-time")/2-1, L"run-time"};const static TLitC< sizeof(L"case-result")/2 > KAtsLoggerTagTestCaseResult={sizeof(L"case-result")/2-1, L"case-result"};const static TLitC< sizeof(L"actual-result")/2 > KAtsLoggerTagActual={sizeof(L"actual-result")/2-1, L"actual-result"};const static TLitC< sizeof(L"debug-info")/2 > KAtsLoggerTagDebug={sizeof(L"debug-info")/2-1, L"debug-info"};const static TLitC< sizeof(L"warning")/2 > KAtsLoggerTagWarning={sizeof(L"warning")/2-1, L"warning"};const static TLitC< sizeof(L"error")/2 > KAtsLoggerTagError={sizeof(L"error")/2-1, L"error"};const static TLitC< sizeof(L"status")/2 > KAtsLoggerTagStatus={sizeof(L"status")/2-1, L"status"};const static TLitC< sizeof(L"time-stamp")/2 > KAtsLoggerTimeStamp={sizeof(L"time-stamp")/2-1, L"time-stamp"};const TInt KAtsLoggerBufferSegmentGranularity=32;class CAtsLogger:public CBase{public:enum TReportStage{ENone, EUninitialized, EBeginTestReport, EBeginTestSet, EBeginTestCase, ESetTestCaseVerdict, EEndTestCase, EEndTestSet, EEndTestReport, EFinished};private:public:IMPORT_C static CAtsLogger *NewL(const TDesC &aName, TBool aAfterReboot=EFalse);IMPORT_C~CAtsLogger();public:IMPORT_C static const TPtrC ErrorMessage(const TInt &aError);IMPORT_C void CloseL();IMPORT_C TBool IsValid();IMPORT_C void BeginTestReportL();IMPORT_C void EndTestReportL();IMPORT_C void SaveForRebootL();IMPORT_C void ContinueAfterRebootL();IMPORT_C void BeginTestSetL(const TDesC &aFactory=KAtsLoggerNa, const TDesC &aComponent=KAtsLoggerNa, const TDesC &aVersion=KAtsLoggerNa, const TDesC &aDescription=KAtsLoggerEmpty);IMPORT_C void EndTestSetL();IMPORT_C void BeginTestCaseL(const TDesC &aId, const TDesC &aExpected=KAtsLoggerNa, const TDesC &aInfo=KAtsLoggerEmpty, const TDesC &aVersion=KAtsLoggerEmpty);IMPORT_C void BeginTestCaseL(const TDesC &aId, const TInt aExpected, const TDesC &aInfo=KAtsLoggerEmpty, const TDesC &aVersion=KAtsLoggerEmpty);IMPORT_C void BeginTestCaseReportL(const TDesC &aId, const TDesC &aExpected, const TTime &aStartTime, const TDesC &aInfo=KAtsLoggerEmpty, const TDesC &aVersion=KAtsLoggerEmpty);IMPORT_C void BeginTestCaseReportL(const TDesC &aId, const TInt aExpected, const TTime &aStartTime, const TDesC &aInfo=KAtsLoggerEmpty, const TDesC &aVersion=KAtsLoggerEmpty);IMPORT_C void EndTestCaseL();IMPORT_C void TestCasePassed();IMPORT_C void TestCaseFailed();IMPORT_C void TestCaseSkipped();IMPORT_C void TestCaseNa();IMPORT_C void SetTestCaseResultL(const TInt aResult);IMPORT_C void SetTestCaseResultL(const TDesC &aResult=KAtsLoggerEmpty);IMPORT_C void SetTestCaseResultL(TRefByValue< const TDesC > aFmt,...);IMPORT_C void DebugL(const TDesC &aMsg);IMPORT_C void DebugL(TRefByValue< const TDesC > aFmt,...);IMPORT_C void WarningL(const TDesC &aMsg);IMPORT_C void WarningL(TRefByValue< const TDesC > aFmt,...);IMPORT_C void ErrorL(const TDesC &aMsg);IMPORT_C void ErrorL(TRefByValue< const TDesC > aFmt,...);IMPORT_C void CommentL(const TDesC &aMsg);IMPORT_C void CommentL(TRefByValue< const TDesC > aFmt,...);IMPORT_C TInt RawLogL(const TDesC &aMsg);IMPORT_C TInt RawLogL(TRefByValue< const TDesC > aFmt,...);IMPORT_C void DebugOutput(const TDesC &aMsg);IMPORT_C void SetFullReporting(TBool aFlag);IMPORT_C void SetDebugOutput(TBool aFlag);IMPORT_C void SetIndentation(TBool aFlag);public:protected:void TagL(const TDesC &aTag, const TDesC &aMsg);void TagL(const TDesC &aTag, const TDesC &aMsg, const TDesC &aAttribute, const TDesC &aValue);void TimeStampedMessageL(const TDesC &aTag, const TDesC &aMsg);void OpenTagL(const TDesC &aTag);void OpenTagL(const TDesC &aTag, const TDesC &aAttribute, const TDesC &aValue);void OpenTagIndentL(const TDesC &aTag);void OpenTagIndentL(const TDesC &aTag, const TDesC &aAttribute, const TDesC &aValue);void CloseTagL(const TDesC &aTag);void CloseTagIndentL(const TDesC &aTag);void LineFeedL();void WriteL(const TDesC &aData, RFile &aFile);void WriteL(const TDesC &aData);HBufC *EncodeLC(const TDesC &aMsg);TBool IsTransitionLegal(const TReportStage &aNewStage);protected:protected:private:void ConstructL(TBool aAfterReboot);CAtsLogger(const TDesC &aName);TBool CheckDirectoryL(const TDesC &aDirName, TChar &aDrive);TInt ReplaceFileL(const TDesC &aFileName);TInt OpenExistingFileL(const TDesC &aFileName);HBufC *FormatDateLC(TDateTime aDate);HBufC *FormatTimeLC(TTimeIntervalMicroSeconds aTime);TInt BufferL(CBufBase *aBufBase, TInt &aLength, const TDesC &aBuf);TInt WriteBufferToFileL(CBufBase *aCBufBase, const TDesC &aFileName);TInt WriteBufferToDebugPortL(CBufBase *aCBufBase);protected:class TTestSet{public:TTime iStartTime;};class TTestCase{public:TTestCase(){iResult=NULL;}~TTestCase(){if(iResult){delete iResult;iResult=NULL;}}public:HBufC *iResult;TPtrC iStatus;TTime iStartTime;};CAtsLogger::TTestSet iTestSet;CAtsLogger::TTestCase iTestCase;CAtsLogger::TReportStage iReportStage;const TFileName iName;private:CBufBase *iXmlBuffer;TInt iXmlBufferLength;int iIndentLevel;RFs iRfs;TFileName iXmlLogFileName;TFileName iRawLogFileName;TBool iRawLog;TBool iXmlLog;TBool iValid;TBool iLineFeedDone;TBool iInTestCase;TBool iClosed;TBool iFullReportingMode;TBool iDoDebugOutput;TBool iDoIndentation;public:protected:private:};#20"X:/sf/os/osrndtools/stif/atslogger/src/atslogger.cpp"2CAtsLogger::CAtsLogger(const TDesC &aName):iReportStage(EUninitialized), iName(aName), iIndentLevel(0), iRawLog(EFalse), iXmlLog(EFalse), iValid(EFalse), iLineFeedDone(EFalse), iInTestCase(EFalse), iClosed(EFalse), iFullReportingMode(ETrue), iDoDebugOutput(EFalse), iDoIndentation(ETrue){}void CAtsLogger::ConstructL(TBool aAfterReboot){TChar xmlDrive;iXmlLog=CheckDirectoryL(KAtsLoggerXmlDirectory, xmlDrive);TChar rawDrive;iRawLog=CheckDirectoryL(KAtsLoggerRawDirectory, rawDrive);if(iXmlLog){iXmlLogFileName.Copy((TPtrC((const TText *) L"?:")));iXmlLogFileName.Append(KAtsLoggerXmlDirectory);iXmlLogFileName.Append(iName);iXmlLogFileName.Append(KAtsLoggerXmlSuffix);iXmlLogFileName[0]=(TUint8) xmlDrive;if(aAfterReboot){User::LeaveIfError(OpenExistingFileL(iXmlLogFileName));}else{User::LeaveIfError(ReplaceFileL(iXmlLogFileName));}iValid=ETrue;}else{iValid=EFalse;}if(iRawLog){iRawLogFileName.Copy((TPtrC((const TText *) L"?:")));iRawLogFileName.Append(KAtsLoggerRawDirectory);iRawLogFileName.Append(iName);iRawLogFileName.Append(KAtsLoggerRawSuffix);iRawLogFileName[0]=(TUint8) rawDrive;if(aAfterReboot){User::LeaveIfError(OpenExistingFileL(iRawLogFileName));}else{User::LeaveIfError(ReplaceFileL(iRawLogFileName));}}iXmlBuffer=CBufSeg::NewL(KAtsLoggerBufferSegmentGranularity);iXmlBufferLength=0;}TBool CAtsLogger::CheckDirectoryL(const TDesC &aDirName, TChar &aDrive){User::LeaveIfError(iRfs.Connect());TDriveList driveList;iRfs.DriveList(driveList);TBool dirFound=EFalse;TFileName dir;for(TInt i=0;i< driveList.Length()&&!dirFound;i++){TChar drive;if(driveList[i]!=0){iRfs.DriveToChar(i, drive);dir.Copy((TPtrC((const TText *) L"?:")));dir.Append(aDirName);dir[0]=(TUint8) drive;RDir rDir;TInt error=rDir.Open(iRfs, dir, KEntryAttNormal);if(error==KErrNone){dirFound=ETrue;aDrive=drive;}else{dirFound=EFalse;aDrive= '?';}rDir.Close();}}iRfs.Close();return dirFound;}TInt CAtsLogger::ReplaceFileL(const TDesC &aFileName){User::LeaveIfError(iRfs.Connect());RFile file;TInt err=file.Replace(iRfs, aFileName, EFileWrite|EFileShareAny);file.Close();iRfs.Close();return err;}TInt CAtsLogger::OpenExistingFileL(const TDesC &aFileName){User::LeaveIfError(iRfs.Connect());RFile file;TInt err=file.Open(iRfs, aFileName, EFileWrite|EFileShareAny);file.Close();iRfs.Close();return err;}EXPORT_C CAtsLogger::~CAtsLogger(){if(!iClosed){CloseL();}if(iXmlBuffer){delete iXmlBuffer;iXmlBuffer=0;}}EXPORT_C void CAtsLogger::CloseL(){if(iClosed){return;}User::LeaveIfError(iRfs.Connect());if(iXmlLog){RFile file;TInt err=file.Open(iRfs, iXmlLogFileName, EFileWrite|EFileShareAny);if(err==KErrNone){TInt fileSize=0;file.Size(fileSize);file.Close();if(fileSize==0){iRfs.Delete(iXmlLogFileName);}}}if(iRawLog){RFile file;TInt err=file.Open(iRfs, iRawLogFileName, EFileWrite|EFileShareAny);if(err==KErrNone){TInt fileSize=0;file.Size(fileSize);file.Close();if(fileSize==0){iRfs.Delete(iRawLogFileName);}}}iRfs.Close();iClosed=ETrue;}EXPORT_C CAtsLogger *CAtsLogger::NewL(const TDesC &aName, TBool aAfterReboot){(void)((aName.Length() > 0)||(User::Leave(KErrBadName),0));RFs rfs;User::LeaveIfError(rfs.Connect());(void)((rfs.IsValidName(aName))||(User::Leave(KErrBadName),0));rfs.Close();CAtsLogger *self=new(ELeave) CAtsLogger(aName);CleanupStack::PushL(self);self->ConstructL(aAfterReboot);CleanupStack::Pop(self);return self;}EXPORT_C TBool CAtsLogger::IsValid(){return iValid;}EXPORT_C void CAtsLogger::BeginTestReportL(){if(iFullReportingMode){if(!IsTransitionLegal(EBeginTestReport)){User::Leave(EBeginTestReport);}iReportStage=EBeginTestReport;OpenTagIndentL(KAtsLoggerTagTestReport());}else{iTestSet.iStartTime.HomeTime();}}EXPORT_C void CAtsLogger::EndTestReportL(){if(iFullReportingMode){if(!IsTransitionLegal(EEndTestReport)){User::Leave(EEndTestReport);}iReportStage=EEndTestReport;CloseTagIndentL(KAtsLoggerTagTestReport());}if(iDoDebugOutput){WriteBufferToDebugPortL(iXmlBuffer);}if(iXmlLog &&!iInTestCase &&iXmlBufferLength > 0){WriteBufferToFileL(iXmlBuffer, iXmlLogFileName);}iXmlBuffer-> Reset

const TLitC< sizeof(L"</")/2 > KAtsLoggerTagClose={sizeof(L"</")/2-1, L"</"};const static TLitC< sizeof(L"\n")/2 > KAtsLoggerLf={sizeof(L"\n")/2-1, L"\n"};const static TLitC< sizeof(L" ")/2 > KAtsLoggerIndent={sizeof(L" ")/2-1, L" "};const static TLitC8< sizeof(" ")> KAtsLoggerIndent8={sizeof(" ")-1," "};const static TLitC< sizeof(L"<!--")/2 > KAtsLoggerCommentOpen={sizeof(L"<!--")/2-1, L"<!--"};const static TLitC< sizeof(L"-->")/2 > KAtsLoggerCommentClose={sizeof(L"-->")/2-1, L"-->"};const static TLitC< sizeof(L"&quot;")/2 > KAtsLoggerQuot={sizeof(L"&quot;")/2-1, L"&quot;"};const static TLitC< sizeof(L"&amp;")/2 > KAtsLoggerAmp={sizeof(L"&amp;")/2-1, L"&amp;"};const static TLitC< sizeof(L"&apos;")/2 > KAtsLoggerApos={sizeof(L"&apos;")/2-1, L"&apos;"};const static TLitC< sizeof(L"&lt;")/2 > KAtsLoggerLt={sizeof(L"&lt;")/2-1, L"&lt;"};const static TLitC< sizeof(L"&gt;")/2 > KAtsLoggerGt={sizeof(L"&gt;")/2-1, L"&gt;"};const static TLitC8< sizeof("&quot;")> KAtsLoggerQuot8={sizeof("&quot;")-1,"&quot;"};const static TLitC8< sizeof("&amp;")> KAtsLoggerAmp8={sizeof("&amp;")-1,"&amp;"};const static TLitC8< sizeof("&apos;")> KAtsLoggerApos8={sizeof("&apos;")-1,"&apos;"};const static TLitC8< sizeof("&lt;")> KAtsLoggerLt8={sizeof("&lt;")-1,"&lt;"};const static TLitC8< sizeof("&gt;")> KAtsLoggerGt8={sizeof("&gt;")-1,"&gt;"};const static TLitC8< sizeof("")> KAtsLoggerEmpty8={sizeof("")-1,""};const static TLitC< sizeof(L"test-report")/2 > KAtsLoggerTagTestReport={sizeof(L"test-report")/2-1, L"test-report"};const static TLitC< sizeof(L"test-batch")/2 > KAtsLoggerTagTestSet={sizeof(L"test-batch")/2-1, L"test-batch"};const static TLitC< sizeof(L"test-case")/2 > KAtsLoggerTagTestCase={sizeof(L"test-case")/2-1, L"test-case"};const static TLitC< sizeof(L"batch-init")/2 > KAtsLoggerTagTestSetInit={sizeof(L"batch-init")/2-1, L"batch-init"};const static TLitC< sizeof(L"description")/2 > KAtsLoggerTagDescription={sizeof(L"description")/2-1, L"description"};const static TLitC< sizeof(L"date")/2 > KAtsLoggerTagDate={sizeof(L"date")/2-1, L"date"};const static TLitC< sizeof(L"factory")/2 > KAtsLoggerTagFactory={sizeof(L"factory")/2-1, L"factory"};const static TLitC< sizeof(L"component")/2 > KAtsLoggerTagComponent={sizeof(L"component")/2-1, L"component"};const static TLitC< sizeof(L"name")/2 > KAtsLoggerTagName={sizeof(L"name")/2-1, L"name"};const static TLitC< sizeof(L"version")/2 > KAtsLoggerTagVersion={sizeof(L"version")/2-1, L"version"};const static TLitC< sizeof(L"batch-result")/2 > KAtsLoggerTagTestSetResult={sizeof(L"batch-result")/2-1, L"batch-result"};const static TLitC< sizeof(L"id")/2 > KAtsLoggerTagId={sizeof(L"id")/2-1, L"id"};const static TLitC< sizeof(L"case-init")/2 > KAtsLoggerTagTestCaseInit={sizeof(L"case-init")/2-1, L"case-init"};const static TLitC< sizeof(L"expected-result")/2 > KAtsLoggerTagExpected={sizeof(L"expected-result")/2-1, L"expected-result"};const static TLitC< sizeof(L"run-time")/2 > KAtsLoggerTagRunTime={sizeof(L"run-time")/2-1, L"run-time"};const static TLitC< sizeof(L"case-result")/2 > KAtsLoggerTagTestCaseResult={sizeof(L"case-result")/2-1, L"case-result"};const static TLitC< sizeof(L"actual-result")/2 > KAtsLoggerTagActual={sizeof(L"actual-result")/2-1, L"actual-result"};const static TLitC< sizeof(L"debug-info")/2 > KAtsLoggerTagDebug={sizeof(L"debug-info")/2-1, L"debug-info"};const static TLitC< sizeof(L"warning")/2 > KAtsLoggerTagWarning={sizeof(L"warning")/2-1, L"warning"};const static TLitC< sizeof(L"error")/2 > KAtsLoggerTagError={sizeof(L"error")/2-1, L"error"};const static TLitC< sizeof(L"status")/2 > KAtsLoggerTagStatus={sizeof(L"status")/2-1, L"status"};const static TLitC< sizeof(L"time-stamp")/2 > KAtsLoggerTimeStamp={sizeof(L"time-stamp")/2-1, L"time-stamp"};const TInt KAtsLoggerBufferSegmentGranularity=32;class CAtsLogger:public CBase{public:enum TReportStage{ENone, EUninitialized, EBeginTestReport, EBeginTestSet, EBeginTestCase, ESetTestCaseVerdict, EEndTestCase, EEndTestSet, EEndTestReport, EFinished};private:public:IMPORT_C static CAtsLogger *NewL(const TDesC &aName, TBool aAfterReboot=EFalse);IMPORT_C~CAtsLogger();public:IMPORT_C static const TPtrC ErrorMessage(const TInt &aError);IMPORT_C void CloseL();IMPORT_C TBool IsValid();IMPORT_C void BeginTestReportL();IMPORT_C void EndTestReportL();IMPORT_C void SaveForRebootL();IMPORT_C void ContinueAfterRebootL();IMPORT_C void BeginTestSetL(const TDesC &aFactory=KAtsLoggerNa, const TDesC &aComponent=KAtsLoggerNa, const TDesC &aVersion=KAtsLoggerNa, const TDesC &aDescription=KAtsLoggerEmpty);IMPORT_C void EndTestSetL();IMPORT_C void BeginTestCaseL(const TDesC &aId, const TDesC &aExpected=KAtsLoggerNa, const TDesC &aInfo=KAtsLoggerEmpty, const TDesC &aVersion=KAtsLoggerEmpty);IMPORT_C void BeginTestCaseL(const TDesC &aId, const TInt aExpected, const TDesC &aInfo=KAtsLoggerEmpty, const TDesC &aVersion=KAtsLoggerEmpty);IMPORT_C void BeginTestCaseReportL(const TDesC &aId, const TDesC &aExpected, const TTime &aStartTime, const TDesC &aInfo=KAtsLoggerEmpty, const TDesC &aVersion=KAtsLoggerEmpty);IMPORT_C void BeginTestCaseReportL(const TDesC &aId, const TInt aExpected, const TTime &aStartTime, const TDesC &aInfo=KAtsLoggerEmpty, const TDesC &aVersion=KAtsLoggerEmpty);IMPORT_C void EndTestCaseL();IMPORT_C void TestCasePassed();IMPORT_C void TestCaseFailed();IMPORT_C void TestCaseSkipped();IMPORT_C void TestCaseNa();IMPORT_C void SetTestCaseResultL(const TInt aResult);IMPORT_C void SetTestCaseResultL(const TDesC &aResult=KAtsLoggerEmpty);IMPORT_C void SetTestCaseResultL(TRefByValue< const TDesC > aFmt,...);IMPORT_C void DebugL(const TDesC &aMsg);IMPORT_C void DebugL(TRefByValue< const TDesC > aFmt,...);IMPORT_C void WarningL(const TDesC &aMsg);IMPORT_C void WarningL(TRefByValue< const TDesC > aFmt,...);IMPORT_C void ErrorL(const TDesC &aMsg);IMPORT_C void ErrorL(TRefByValue< const TDesC > aFmt,...);IMPORT_C void CommentL(const TDesC &aMsg);IMPORT_C void CommentL(TRefByValue< const TDesC > aFmt,...);IMPORT_C TInt RawLogL(const TDesC &aMsg);IMPORT_C TInt RawLogL(TRefByValue< const TDesC > aFmt,...);IMPORT_C void DebugOutput(const TDesC &aMsg);IMPORT_C void SetFullReporting(TBool aFlag);IMPORT_C void SetDebugOutput(TBool aFlag);IMPORT_C void SetIndentation(TBool aFlag);public:protected:void TagL(const TDesC &aTag, const TDesC &aMsg);void TagL(const TDesC &aTag, const TDesC &aMsg, const TDesC &aAttribute, const TDesC &aValue);void TimeStampedMessageL(const TDesC &aTag, const TDesC &aMsg);void OpenTagL(const TDesC &aTag);void OpenTagL(const TDesC &aTag, const TDesC &aAttribute, const TDesC &aValue);void OpenTagIndentL(const TDesC &aTag);void OpenTagIndentL(const TDesC &aTag, const TDesC &aAttribute, const TDesC &aValue);void CloseTagL(const TDesC &aTag);void CloseTagIndentL(const TDesC &aTag);void LineFeedL();void WriteL(const TDesC &aData, RFile &aFile);void WriteL(const TDesC &aData);HBufC *EncodeLC(const TDesC &aMsg);TBool IsTransitionLegal(const TReportStage &aNewStage);protected:protected:private:void ConstructL(TBool aAfterReboot);CAtsLogger(const TDesC &aName);TBool CheckDirectoryL(const TDesC &aDirName, TChar &aDrive);TInt ReplaceFileL(const TDesC &aFileName);TInt OpenExistingFileL(const TDesC &aFileName);HBufC *FormatDateLC(TDateTime aDate);HBufC *FormatTimeLC(TTimeIntervalMicroSeconds aTime);TInt BufferL(CBufBase *aBufBase, TInt &aLength, const TDesC &aBuf);TInt WriteBufferToFileL(CBufBase *aCBufBase, const TDesC &aFileName);TInt WriteBufferToDebugPortL(CBufBase *aCBufBase);protected:class TTestSet{public:TTime iStartTime;};class TTestCase{public:TTestCase(){iResult=NULL;}~TTestCase(){if(iResult){delete iResult;iResult=NULL;}}public:HBufC *iResult;TPtrC iStatus;TTime iStartTime;};CAtsLogger::TTestSet iTestSet;CAtsLogger::TTestCase iTestCase;CAtsLogger::TReportStage iReportStage;const TFileName iName;private:CBufBase *iXmlBuffer;TInt iXmlBufferLength;int iIndentLevel;RFs iRfs;TFileName iXmlLogFileName;TFileName iRawLogFileName;TBool iRawLog;TBool iXmlLog;TBool iValid;TBool iLineFeedDone;TBool iInTestCase;TBool iClosed;TBool iFullReportingMode;TBool iDoDebugOutput;TBool iDoIndentation;public:protected:private:};#20"X:/sf/os/osrndtools/stif/atslogger/src/atslogger.cpp"2CAtsLogger::CAtsLogger(const TDesC &aName):iReportStage(EUninitialized), iName(aName), iIndentLevel(0), iRawLog(EFalse), iXmlLog(EFalse), iValid(EFalse), iLineFeedDone(EFalse), iInTestCase(EFalse), iClosed(EFalse), iFullReportingMode(ETrue), iDoDebugOutput(EFalse), iDoIndentation(ETrue){}void CAtsLogger::ConstructL(TBool aAfterReboot){TChar xmlDrive;iXmlLog=CheckDirectoryL(KAtsLoggerXmlDirectory, xmlDrive);TChar rawDrive;iRawLog=CheckDirectoryL(KAtsLoggerRawDirectory, rawDrive);if(iXmlLog){iXmlLogFileName.Copy((TPtrC((const TText *) L"?:")));iXmlLogFileName.Append(KAtsLoggerXmlDirectory);iXmlLogFileName.Append(iName);iXmlLogFileName.Append(KAtsLoggerXmlSuffix);iXmlLogFileName[0]=(TUint8) xmlDrive;if(aAfterReboot){User::LeaveIfError(OpenExistingFileL(iXmlLogFileName));}else{User::LeaveIfError(ReplaceFileL(iXmlLogFileName));}iValid=ETrue;}else{iValid=EFalse;}if(iRawLog){iRawLogFileName.Copy((TPtrC((const TText *) L"?:")));iRawLogFileName.Append(KAtsLoggerRawDirectory);iRawLogFileName.Append(iName);iRawLogFileName.Append(KAtsLoggerRawSuffix);iRawLogFileName[0]=(TUint8) rawDrive;if(aAfterReboot){User::LeaveIfError(OpenExistingFileL(iRawLogFileName));}else{User::LeaveIfError(ReplaceFileL(iRawLogFileName));}}iXmlBuffer=CBufSeg::NewL(KAtsLoggerBufferSegmentGranularity);iXmlBufferLength=0;}TBool CAtsLogger::CheckDirectoryL(const TDesC &aDirName, TChar &aDrive){User::LeaveIfError(iRfs.Connect());TDriveList driveList;iRfs.DriveList(driveList);TBool dirFound=EFalse;TFileName dir;for(TInt i=0;i< driveList.Length()&&!dirFound;i++){TChar drive;if(driveList[i]!=0){iRfs.DriveToChar(i, drive);dir.Copy((TPtrC((const TText *) L"?:")));dir.Append(aDirName);dir[0]=(TUint8) drive;RDir rDir;TInt error=rDir.Open(iRfs, dir, KEntryAttNormal);if(error==KErrNone){dirFound=ETrue;aDrive=drive;}else{dirFound=EFalse;aDrive= '?';}rDir.Close();}}iRfs.Close();return dirFound;}TInt CAtsLogger::ReplaceFileL(const TDesC &aFileName){User::LeaveIfError(iRfs.Connect());RFile file;TInt err=file.Replace(iRfs, aFileName, EFileWrite|EFileShareAny);file.Close();iRfs.Close();return err;}TInt CAtsLogger::OpenExistingFileL(const TDesC &aFileName){User::LeaveIfError(iRfs.Connect());RFile file;TInt err=file.Open(iRfs, aFileName, EFileWrite|EFileShareAny);file.Close();iRfs.Close();return err;}EXPORT_C CAtsLogger::~CAtsLogger(){if(!iClosed){CloseL();}if(iXmlBuffer){delete iXmlBuffer;iXmlBuffer=0;}}EXPORT_C void CAtsLogger::CloseL(){if(iClosed){return;}User::LeaveIfError(iRfs.Connect());if(iXmlLog){RFile file;TInt err=file.Open(iRfs, iXmlLogFileName, EFileWrite|EFileShareAny);if(err==KErrNone){TInt fileSize=0;file.Size(fileSize);file.Close();if(fileSize==0){iRfs.Delete(iXmlLogFileName);}}}if(iRawLog){RFile file;TInt err=file.Open(iRfs, iRawLogFileName, EFileWrite|EFileShareAny);if(err==KErrNone){TInt fileSize=0;file.Size(fileSize);file.Close();if(fileSize==0){iRfs.Delete(iRawLogFileName);}}}iRfs.Close();iClosed=ETrue;}EXPORT_C CAtsLogger *CAtsLogger::NewL(const TDesC &aName, TBool aAfterReboot){(void)((aName.Length() > 0)||(User::Leave(KErrBadName),0));RFs rfs;User::LeaveIfError(rfs.Connect());(void)((rfs.IsValidName(aName))||(User::Leave(KErrBadName),0));rfs.Close();CAtsLogger *self=new(ELeave) CAtsLogger(aName);CleanupStack::PushL(self);self->ConstructL(aAfterReboot);CleanupStack::Pop(self);return self;}EXPORT_C TBool CAtsLogger::IsValid(){return iValid;}EXPORT_C void CAtsLogger::BeginTestReportL(){if(iFullReportingMode){if(!IsTransitionLegal(EBeginTestReport)){User::Leave(EBeginTestReport);}iReportStage=EBeginTestReport;OpenTagIndentL(KAtsLoggerTagTestReport());}else{iTestSet.iStartTime.HomeTime();}}EXPORT_C void CAtsLogger::EndTestReportL(){if(iFullReportingMode){if(!IsTransitionLegal(EEndTestReport)){User::Leave(EEndTestReport);}iReportStage=EEndTestReport;CloseTagIndentL(KAtsLoggerTagTestReport());}if(iDoDebugOutput){WriteBufferToDebugPortL(iXmlBuffer);}if(iXmlLog &&!iInTestCase &&iXmlBufferLength > 0){WriteBufferToFileL(iXmlBuffer, iXmlLogFileName);}iXmlBuffer->Reset[static]

iXmlBufferLength

iXmlBufferLength