// testELassert.cc -- Test of ELassert mechanism // // Either put the define conditions here or do them when compiling: // #define NDEBUG3 // #define NDEBUG2 // #define NDEBUG1 // #define NDEBUG #define NOSANCHECK // ----------------- // Physicsists' Code // ----------------- #include "testELassert.h" #include "ErrorLogger/ErrorLog.h" #include "ErrorLogger/ELassertN.h" // This is the only ErrorLogger-related include the user normally needs. void DoPhysics::operator()( Event & event ) { // THIS METHOD IS WHERE ALL THE PHYSICS CALCULATION WOULD GO. errlog( ELsuccess, "An Event" ) << "data = " << event.data << endmsg; int level; std::cout << "Enter assert level to test - add ten for warning: "; std::cin >> level; switch (level) { case 0: ELassert (level == 100); std::cout << "tested ELassert \n"; break; case 1: ELassert1 (level == 100); std::cout << "tested ELassert1 \n"; break; case 2: ELassert2 (level == 100); std::cout << "tested ELassert2 \n"; break; case 3: ELassert3 (level == 100); std::cout << "tested ELassert3 \n"; break; case 4: ELsanityCheck (level == 100); std::cout << "tested ELsanityCheck \n"; break; case 10: ELwarningAssert (level == 100); std::cout << "tested ELwarningAssert \n"; break; case 11: ELwarningAssert1 (level == 100); std::cout << "tested ELwarningAssert1 \n"; break; case 12: ELwarningAssert2 (level == 100); std::cout << "tested ELwarningAssert2 \n"; break; case 13: ELwarningAssert3 (level == 100); std::cout << "tested ELwarningAssert3 \n"; break; case 14: ELwarningCheck (level == 100); std::cout << "tested ELwarningCheck \n"; break; default: std::cout << "That is not a valid option\n"; } errlog( ELsuccess, "Event Done" ) << "data = " << event.data << endmsg; } // DoPhysics::operator()(event) // --------------- // Framework Code // --------------- #include "testELassert.h" // The framework would normally include some framework.h, plus Event.h, // Module.h, and the headers for any physicist classes like DoPhysics. // In our illustration these are all in basicUsage.h. // These are the ErrorLogger classes used by the typical framework: #include "ErrorLogger/ELadministrator.h" #include "ErrorLogger/ELdestControl.h" #include "ErrorLogger/ELoutput.h" #include "ErrorLogger/ELstatistics.h" #include "ZMutility/iostream" USING( std::cout ) Module::Module( const std::string & name ) { errlog.setModule( name ); } int main() { ELadministrator * logger = ELadministrator::instance(); // instantiate a logger object ELoutput logfileD( "ELassert.errlog" ); // make an ELdestination ELdestControl logfile ( logger->attach(logfileD) ); // tell logger about it logfile.setThreshold ( ELsuccess ); // ignore messages below // ELsucess ELoutput outputD( cout ); // another ELdestination ELdestControl output ( logger->attach(outputD) ); // tell logger about it output.setThreshold ( ELwarning ); // ignore messages below // ELwarning ELstatistics statsD( cout ); // a statistics dest ELdestControl stats ( logger->attach(statsD) ); // tell logger about it // The following is a list of the modules in this program: DoPhysics doPhysics( "PHYSICS CODE" ); // There is only one module in this illustration. int n; for ( n = 1; n < 100; ++n ) { Event event( n ); doPhysics( event ); } return 0; } // main()