// ShortFrame5.cc // // // Tests priority of setting limits. // Tests wipe() and zero() // Also tests when errlog captures the module, subroutine, timestamp, etc. #include "ErrorLogger/ELadministrator.h" #include "ErrorLogger/ELdestControl.h" #include "ErrorLogger/ELoutput.h" #include "ErrorLogger/ELstatistics.h" ZM_USING_NAMESPACE( zmel ) #include "ShortFrame5.h" #include "SampleEvent.h" #include "ShortModule.h" #include "ZMutility/iostream" USING( std::cout ) USING( std::endl ) USING( std::cin ) int main() { ShortFrame5 framework; framework.SetupAndRun(); return 0; } ShortFrame5::ShortFrame5(){ step = new ShortModule("Short"); } ShortFrame5::~ShortFrame5(){ delete step; } void ShortFrame5::SetupAndRun(){ logger = ELadministrator::instance(); errlog.setModule("Old Module"); errlog.setSubroutine("Old Subroutine"); output = logger->attach(ELoutput(cout)); output.setThreshold(ELwarning); output.setLimit("Error", 9); // $$ 13:5 output.setLimit("*", 7); logfile = logger->attach(ELoutput("blah.log")); logfile.setLimit("Error", 9); // $$ 13:5 logfile.setLimit(ELerror, 7); file2 = logger->attach(ELoutput("stuff.log")); file2.setLimit(ELerror, 9); // $$ 13:5 file2.setLimit("*", 7); stats = logger->attach(ELstatistics(cout)); errlog (ELsuccess, "Starting up.") << endmsg; errlog (ELsuccess, "Change this log"); //no endmsg Pause(); //trying to change: timestamp, $$ 3:1 errlog.setModule("New Module"); // module name, errlog.setSubroutine("New Subroutine"); // subroutine //before ending errror message. Event event; event.datum = 0; cout << "Invoke() being called once" << endl; step->invoke(event); cout << "Invoke() finished" << endl; stats.summary(output); stats.summary(logfile); stats.summary(file2); output.wipe(); //cout will now show all errors (limit deleted) $$ 16:3 file2.zero(); //"stuff.log" will show 9 errors on the next call $$ 16:5 //to invoke() because it reset limit count event.datum = 0; cout << "Invoke() being called again" << endl; step->invoke(event); cout << "Invoke() finished" << endl; stats.summary(output); stats.summary(logfile); stats.summary(file2); logger->wipe(); //deletes all limits so all errors are logged $$ 16:4 event.datum = 0; cout << "Invoke() being called one last time" << endl; step->invoke(event); cout << "Invoke() finished" << endl; errlog(ELzeroSeverity, "Finished module.") << endmsg; stats.summary(output); stats.summary(logfile); stats.summary(file2); } void Pause(){ int blah; cout << "Pausing... Please enter an integer to continue: "; cin >> blah; } #include "ShortModule.cc"