/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/ers/ers-00-00-03/test/test.cxx

Go to the documentation of this file.
00001 /*
00002  *  ExampleIssue.h
00003  *  Test
00004  *
00005  *  Created by Matthias Wiesmann on 24.01.05.
00006  *  Copyright 2005 CERN. All rights reserved.
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 } // foo
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     } // for 
00037 } // 
00038 
00039 int main(int argc, char** argv) {
00040     for(int i=1;i<argc;i++) { // we add all parameters as qualifiers
00041         ers::Context::add_qualifier(argv[i]) ; 
00042     } // 
00043     ers::Context::add_qualifier("ers_test") ;   // we add a qualifier to all issues 
00044     try { // We need to work with a try/catch block 
00045         massive_test(); 
00046         ers::StreamFactory::set_stream(ers::debug_3,"filter:?!ers_test,ers_failure@default"); // we filter out all issue with qualifier ers_test at level debug_3
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); // we build an instance of our Issue
00052         ers::StreamFactory::dispatch(issue);   // dispatch sends it to the correct stream based on severity
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) { // we catch issues and send them to the warning stream 
00059         ers::StreamFactory::warning(&e); 
00060     }
00061     return 0 ; 
00062 } // main 
00063 

Generated on Tue Nov 29 22:58:02 2016 for BOSS_7.0.2 by  doxygen 1.4.7