// TFrames.cc - // // Similar to TestFramework.cc with minor alterations // This framework uses TestModule and TestModuleA as well // // #include "ErrorLogger/ELadministrator.h" #include "ErrorLogger/ELdestControl.h" #include "ErrorLogger/ELoutput.h" #include "ErrorLogger/ELstatistics.h" #include "ErrorLogger/ErrorObj.h" ZM_USING_NAMESPACE( zmel ) #include "ZMutility/iostream" USING( std::cout ) USING( std::endl ) #include USING( std::string ) #include "TFrames.h" #include "SampleEvent.h" #include "TestModule.h" #include "TestModuleA.h" TFrames::RunEventContext::RunEventContext( TFrames &ff) : f(ff) { } ZM_COVARIANT_TYPE(ELcontextSupplier *, TFrames::RunEventContext *) TFrames::RunEventContext::clone() const { return new TFrames::RunEventContext(*this); } string TFrames::RunEventContext::context() const{return "";} string TFrames::RunEventContext::summaryContext() const{return "";} string TFrames::RunEventContext::fullContext() const{return "";} void TFrames::RunEventContext::editErrorObj(ErrorObj &msg) const{ // $$ 12:4 msg << "This message is coming from editErrorObj."; } ELstring TFrames::RunEventContext::traceRoutine() const{ // $$ 12:5 ELstring nothing = "This is outputted by traceRoutine."; return nothing; } int main() { TFrames framework; framework.setup(); framework.eventLoop(); return 0; } TFrames::TFrames():reContext(*this) { step = new TestModuleA(); } TFrames::~TFrames(){ delete step; } void TFrames::setup(){ logger = ELadministrator::instance(); logger->setProcess(" Something else "); logger->setContextSupplier( reContext ); logger->setAbortThreshold(ELhighestSeverity); logfile = logger->attach(ELoutput ("everything.log")); logfile.setThreshold (ELzeroSeverity); logfile.setTraceThreshold (ELunspecified); // $$ 19:1 part1log = logger->attach(ELoutput ("successes.log")); part1log.setThreshold (ELsuccess); //No trace threshold set $$ 19:2 //Default is ELhighestSeverity output = logger->attach(ELoutput(cout)); output.suppressSubroutine(); // $$ 24:3 output.suppressText(); // $$ 24:4 output.setThreshold (ELzeroSeverity); stats = logger->attach(ELstatistics ()); // $$ 15:9 stats.setThreshold (ELsuccess); errlog.setModule ("TFrames"); //all errlogs in TFrames will have $$11:2 //this attached while errlogs from TestModuleA will //attach some other module name } void TFrames::eventLoop(){ Event event; event.datum = 0; errlog(ELsuccess, "Event started.") << endmsg; int n=210; ErrorObj myMsg ( ELwarning, "Suspicious Pt" ); // $$ 4:1 do{ logger->resetSeverityCount(); // $$ 18:5 if (n<210) myMsg << "\nDidn't work with n =" << n << endmsg; // $$ 4:3 n = n-10; event.datum = 0; cout << "\n\t\t *** New Trial- Attempting with n=" << n << " ***\n\n" << endl; for (int i=0; iinvoke(event); stats.summary(output); } while (logger->severityCount(ELerror) > 10); myMsg << "\n** Works with n =" << n << "**\n" << endmsg; errlog(myMsg); // $$ 4:2 myMsg << "\nErrors before wipe:" << logger->severityCount(ELerror); stats.wipe(); // $$ 16:2 stats.summary(output); stats.summary(logfile); myMsg << "\nErrors after wipe:" << logger->severityCount(ELerror); logger->resetSeverityCount(ELerror); // $$ 18:3 myMsg << "\nErrors after reseting severity count:" << logger->severityCount(ELerror) << "\n"; myMsg.setModule("TFrames.cc"); // $$ 29:2 myMsg.setSubroutine("None"); // $$ 29:3 bool reacted = logfile.log (myMsg); //This should send myMsg to $$ 29:1 //the logfile "everything.log" cout << "\nmyMsg was sent to the logfile a second time? " << reacted << "\n\n"; errlog(ELhighestSeverity, "Checking default trace Threshold")<