BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/ers/ers-00-00-03/test/test.cxx File Reference
#include "ers/ers.h"
#include "ExampleIssue.h"

Go to the source code of this file.

Functions

void foo (int n)
 
void massive_test ()
 
int main (int argc, char **argv)
 

Detailed Description

This file contains a very simple example of using ERS. Basically, we use the custom issue defined in ExampleIssue.

Definition in file Event/ers/ers-00-00-03/test/test.cxx.

Function Documentation

◆ foo()

void foo ( int  n)

This function illustrates the usage of range checking macros.

Parameters
nan integer excepted to be between 0 and 42.

Definition at line 26 of file Event/ers/ers-00-00-03/test/test.cxx.

26 {
27 ERS_RANGE_CHECK(0,n,42) ;
28 ERS_DEBUG_0("function foo called with value %d",n);
29} // foo
const Int_t n
#define ERS_RANGE_CHECK(min, value, max)

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 39 of file Event/ers/ers-00-00-03/test/test.cxx.

39 {
40 for(int i=1;i<argc;i++) { // we add all parameters as qualifiers
42 } //
43 ers::Context::add_qualifier("ers_test") ; // we add a qualifier to all issues
44 try { // We need to work with a try/catch block
45 massive_test();
46 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
47 ERS_DEBUG_3("This should not be displayed");
48 ERS_DEBUG_0("checking static assert");
49 ERS_STATIC_ASSERT(sizeof(int)==4);
50 ERS_DEBUG_0("dispatching custom issue to warning stream");
51 ExampleIssue issue(ERS_HERE,ers::warning,10); // we build an instance of our Issue
52 ers::StreamFactory::dispatch(issue); // dispatch sends it to the correct stream based on severity
53 ERS_DEBUG_0("calling a method with wrong range");
54 foo(43);
55 ERS_DEBUG_0("done - if we reached this point, assertion have been disabled - this can be done by defining the N_DEBUG macro");
56 ERS_DEBUG_0("throwing custom issue");
58 } catch (ers::Issue &e) { // we catch issues and send them to the warning stream
60 }
61 return 0 ;
62} // main
#define ERS_STATIC_ASSERT(expr)
Example issue.
Definition: ExampleIssue.h:20
static void add_qualifier(const std::string &qualif)
Definition: Context.cxx:56
static void set_stream(severity_t, const std::string &key)
Stream * warning()
Warning stream.
static void dispatch(Issue *i, bool throw_error=false)
Sends an issue to the appropriate stream according to its severity_t.

◆ massive_test()

void massive_test ( )

Definition at line 31 of file Event/ers/ers-00-00-03/test/test.cxx.

31 {
33 ERS_DEBUG_0("dumping a lot of log issues");
34 for(int i=0;i<1000000;i++) {
35 ERS_DEBUG_2("dump %d",i);
36 } // for
37} //

Referenced by main().