00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "ers/ers.h"
00013 #include "ExampleIssue.h"
00014
00015
00016
00026 void foo(int n) {
00027 ERS_RANGE_CHECK(0,n,42) ;
00028 ERS_DEBUG_0("function foo called with value %d",n);
00029 }
00030
00031 void massive_test() {
00032 ers::StreamFactory::set_stream(ers::debug_2,"null");
00033 ERS_DEBUG_0("dumping a lot of log issues");
00034 for(int i=0;i<1000000;i++) {
00035 ERS_DEBUG_2("dump %d",i);
00036 }
00037 }
00038
00039 int main(int argc, char** argv) {
00040 for(int i=1;i<argc;i++) {
00041 ers::Context::add_qualifier(argv[i]) ;
00042 }
00043 ers::Context::add_qualifier("ers_test") ;
00044 try {
00045 massive_test();
00046 ers::StreamFactory::set_stream(ers::debug_3,"filter:?!ers_test,ers_failure@default");
00047 ERS_DEBUG_3("This should not be displayed");
00048 ERS_DEBUG_0("checking static assert");
00049 ERS_STATIC_ASSERT(sizeof(int)==4);
00050 ERS_DEBUG_0("dispatching custom issue to warning stream");
00051 ExampleIssue issue(ERS_HERE,ers::warning,10);
00052 ers::StreamFactory::dispatch(issue);
00053 ERS_DEBUG_0("calling a method with wrong range");
00054 foo(43);
00055 ERS_DEBUG_0("done - if we reached this point, assertion have been disabled - this can be done by defining the N_DEBUG macro");
00056 ERS_DEBUG_0("throwing custom issue");
00057 throw ExampleIssue(ERS_HERE,ers::error,25);
00058 } catch (ers::Issue &e) {
00059 ers::StreamFactory::warning(&e);
00060 }
00061 return 0 ;
00062 }
00063