// testHex -- Illustration of using the setHexTrigger feature of // ErrorLogger mechanism. // // This example program is in two logical pieces: // // First we show the user code -- many physicist users could contribute // code of this nature, using errlog in the manner shown. // // Then we show the framework code that would support this. One // programmer sets up this framework to coordinate all code. The // framework controls things like which output destinations exist and // what sort of messages to pass to each destination. // // THIS FRAMEWORK IS A VERY MINIMAL EXAMPLE for illustration. // // ----------------- // Physicsists' Code // ----------------- #include "testHex.h" #include "ErrorLogger/ErrorLog.h" ZM_USING_NAMESPACE(zmel) void DoPhysics::operator()( Event & event ) { int xint; long xlong; short xshort; unsigned int xuint; unsigned long xulong; unsigned short xushort; if (event.data > -500) { errlog.setHexTrigger ( event.data ); errlog(ELerror, "SET") << "hex trigger =" << event.data << endmsg; } // First, some ints. xint = -2; errlog( ELinfo, "int" ) << xint << endmsg; xint = -1; errlog( ELinfo, "int" ) << xint << endmsg; xint = 0; errlog( ELinfo, "int" ) << xint << endmsg; xint = 1; errlog( ELinfo, "int" ) << xint << endmsg; xint = 2; errlog( ELerror, "int" ) << xint << endmsg; xint = 99; errlog( ELinfo, "int" ) << xint << endmsg; xint = 100; errlog( ELinfo, "int" ) << xint << endmsg; xint = 101; errlog( ELerror, "int" ) << xint << endmsg; xint = -99; errlog( ELerror, "int" ) << xint << endmsg; xint = -100; errlog( ELinfo, "int" ) << xint << endmsg; xint = -101; errlog( ELerror, "int" ) << xint << endmsg; xint = 0x123456; errlog( ELerror, "int" ) << xint << endmsg; xint = - 0x54321; errlog( ELerror, "int" ) << xint << endmsg; // Next some longs xlong = -2; errlog( ELinfo, "long" ) << xlong << endmsg; xlong = -1; errlog( ELinfo, "long" ) << xlong << endmsg; xlong = 0; errlog( ELinfo, "long" ) << xlong << endmsg; xlong = 1; errlog( ELinfo, "long" ) << xlong << endmsg; xlong = 2; errlog( ELerror, "long" ) << xlong << endmsg; xlong = 99; errlog( ELinfo, "long" ) << xlong << endmsg; xlong = 100; errlog( ELinfo, "long" ) << xlong << endmsg; xlong = 101; errlog( ELerror, "long" ) << xlong << endmsg; xlong = -99; errlog( ELerror, "long" ) << xlong << endmsg; xlong = -100; errlog( ELinfo, "long" ) << xlong << endmsg; xlong = -101; errlog( ELerror, "long" ) << xlong << endmsg; xlong = 0x123456; errlog( ELerror, "long" ) << xlong << endmsg; xlong = - 0x54321; errlog( ELerror, "long" ) << xlong << endmsg; // Now some shorts xshort = -2; errlog( ELinfo, "short" ) << xshort << endmsg; xshort = -1; errlog( ELinfo, "short" ) << xshort << endmsg; xshort = 0; errlog( ELinfo, "short" ) << xshort << endmsg; xshort = 1; errlog( ELinfo, "short" ) << xshort << endmsg; xshort = 2; errlog( ELerror, "short" ) << xshort << endmsg; xshort = 99; errlog( ELinfo, "short" ) << xshort << endmsg; xshort = 100; errlog( ELinfo, "short" ) << xshort << endmsg; xshort = 101; errlog( ELerror, "short" ) << xshort << endmsg; xshort = -99; errlog( ELerror, "short" ) << xshort << endmsg; xshort = -100; errlog( ELinfo, "short" ) << xshort << endmsg; xshort = -101; errlog( ELerror, "short" ) << xshort << endmsg; xshort = 0x1234; errlog( ELerror, "short" ) << xshort << endmsg; xshort = - 0x321; errlog( ELerror, "short" ) << xshort << endmsg; // On to unsigned ints... xuint = 0; errlog( ELinfo, "uint" ) << xuint << endmsg; xuint = 1; errlog( ELinfo, "uint" ) << xuint << endmsg; xuint = 2; errlog( ELerror, "uint" ) << xuint << endmsg; xuint = 99; errlog( ELinfo, "uint" ) << xuint << endmsg; xuint = 100; errlog( ELinfo, "uint" ) << xuint << endmsg; xuint = 101; errlog( ELerror, "uint" ) << xuint << endmsg; xuint = 0xFFFFFF88; errlog( ELerror, "uint" ) << xuint << endmsg; xuint = 0xFFFFFF9A; errlog( ELinfo, "uint" ) << xuint << endmsg; xuint = 0xFFFFFF9B; errlog( ELerror, "uint" ) << xuint << endmsg; xuint = 0x123456; errlog( ELerror, "uint" ) << xuint << endmsg; xuint = 0xEDC54321; errlog( ELerror, "uint" ) << xuint << endmsg; // And unsigned longs xulong = 0; errlog( ELinfo, "ulong" ) << xulong << endmsg; xulong = 1; errlog( ELinfo, "ulong" ) << xulong << endmsg; xulong = 2; errlog( ELerror, "ulong" ) << xulong << endmsg; xulong = 99; errlog( ELinfo, "ulong" ) << xulong << endmsg; xulong = 100; errlog( ELinfo, "ulong" ) << xulong << endmsg; xulong = 101; errlog( ELerror, "ulong" ) << xulong << endmsg; xulong = 0xFFFFFF88; errlog( ELerror, "ulong" ) << xulong << endmsg; xulong = 0xFFFFFF9A; errlog( ELinfo, "ulong" ) << xulong << endmsg; xulong = 0xFFFFFF9B; errlog( ELerror, "ulong" ) << xulong << endmsg; xulong = 0x123456; errlog( ELerror, "ulong" ) << xulong << endmsg; xulong = 0xEDC54321; errlog( ELerror, "ulong" ) << xulong << endmsg; // Finally, unsigned shorts xushort = 0; errlog( ELinfo, "ushort" ) << xushort << endmsg; xushort = 1; errlog( ELinfo, "ushort" ) << xushort << endmsg; xushort = 2; errlog( ELerror, "ushort" ) << xushort << endmsg; xushort = 99; errlog( ELinfo, "ushort" ) << xushort << endmsg; xushort = 100; errlog( ELinfo, "ushort" ) << xushort << endmsg; xushort = 101; errlog( ELerror, "ushort" ) << xushort << endmsg; xushort = 0xFF88; errlog( ELerror, "ushort" ) << xushort << endmsg; xushort = 0xFF9A; errlog( ELinfo, "ushort" ) << xushort << endmsg; xushort = 0xFF9B; errlog( ELerror, "ushort" ) << xushort << endmsg; xushort = 0x1234; errlog( ELerror, "ushort" ) << xushort << endmsg; xushort = 0xEDCB; errlog( ELerror, "ushort" ) << xushort << endmsg; return; } // DoPhysics::operator()(event) // --------------- // Framework Code // --------------- #include "testHex.h" #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( "testStatsMap.errlog" ); // make an ELdestination ELdestControl logfile ( logger->attach(logfileD) ); // tell logger about it logfile.setThreshold ( ELinfo ); // ignore messages below // ELinfo ELoutput outputD( cout ); // another ELdestination ELdestControl output ( logger->attach(outputD) ); // tell logger about it output.setThreshold ( ELerror ); // ignore messages below // ELerror ELstatistics statsD( cout ); // a statistics dest ELdestControl stats ( logger->attach(statsD) ); // tell logger about it stats.setThreshold ( ELinfo ); // ignore messages below // ELinfo // The following is a list of the modules in this program: DoPhysics doPhysics( "PHYSICS CODE" ); // There is only one module in this illustration. for ( int n=1 ; n <= 2; ++n ) { Event event( n - 1000 ); doPhysics( event ); } for ( int n=1 ; n <= 2; ++n ) { Event event( n+100 ); doPhysics( event ); } for ( int n=1 ; n <= 2; ++n ) { Event event( n-1 ); doPhysics( event ); } for ( int n=1 ; n <= 2; ++n ) { Event event( n-3 ); doPhysics( event ); } return 0; } // main()