// ShortFrame3.cc // // Tests limits and timespans. // // // #include "ErrorLogger/ELadministrator.h" #include "ErrorLogger/ELdestControl.h" #include "ErrorLogger/ELoutput.h" #include "ErrorLogger/ELstatistics.h" ZM_USING_NAMESPACE( zmel ) #include "ShortFrame3.h" #include "SampleEvent.h" #include "ShortModule.h" #include "ZMutility/iostream" USING( std::cout ) USING( std::cin ) USING( std::endl ) #include USING( std::string ) int main() { ShortFrame3 framework; framework.SetupAndRun(); return 0; } ShortFrame3::ShortFrame3(){ step = new ShortModule("Short"); } ShortFrame3::~ShortFrame3(){ delete step; } void ShortFrame3::SetupAndRun(){ logger = ELadministrator::instance(); output = logger->attach(ELoutput(cout)); logfile = logger->attach(ELoutput("short3.log")); stats = logger->attach(ELstatistics(cout)); logger->setThresholds(ELinfo); // $$ 13:8 /*EXPECTED LIMIT AND TIMESPAN RESULTS If the user waits < 3 seconds: cout gets 3 ELinfos, 9 ELerrors, and 10 ELwarnings. logfile gets 3 ELinfos, 13 ELerrors, and 10 ELwarnings. If the user waits > 3 but < 10 seconds: cout should get 5 ELinfos, 9 ELerrors, and 10 ELwarnings. logfile should get 5 ELinfos, 24 ELerrors, and 10 ELwarnings. If the user waits > 10 seconds: cout gets 5 ELinfos, 14 ELerrors, and 14 ELwarnings logfile gets 5 ELinfos, 24 ELerrors, and 14 ELwarnings. */ output.setLimit("Error", 7); output.setTimespan("Error", 10); // $$ 20:1 logger->setLimits("Info Log.", 3); // $$ 13:8 logger->setLimits(ELwarning, 5); logger->setLimits("*", 12); logger->setTimespans(ELwarning, 10); // $$ 20:5 logger->setTimespans("*", 3); // $$ 20:6 ERRLOGTO(errlog, ELsuccess, "Starting up.") << endmsg; // $$ 2:4 for (int i=0; i<3; i++) { errlog(ELinfo, "Info Log.") << endmsg; } for (int i=0; i<5; i++) { errlog(ELwarning, "Warning Loop.") << i+1 << endmsg; } Event event; event.datum = 0; step->invoke(event); Pause(); event.datum = 0; step->invoke(event); for (int i=0; i<2; i++) { errlog(ELinfo, "Info Log.") << endmsg; } for (int i=5; i<85; i++) { //i=10,15,25,45,85 should be logged $$ 13:10 errlog(ELwarning, "Warning Loop.") << i+1 << endmsg; //after limit } //is reached and pause is < 3 secs ERRLOGTO(errlog, ELsuccess, "Finished.") << endmsg; stats.summary(logfile); stats.summary(cout); } void Pause(){ int blah; cout << "Pausing... Please enter an integer to continue: "; cin >> blah; } #include "ShortModule.cc"