BOSS
8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/ers/test/test.cxx
Go to the documentation of this file.
1
/*
2
* ExampleIssue.h
3
* Test
4
*
5
* Created by Matthias Wiesmann on 24.01.05.
6
* Copyright 2005 CERN. All rights reserved.
7
*
8
*/
9
10
#include "
ExampleIssue.h
"
11
#include "ers/ers.h"
12
13
/** \file test.cxx
14
* This file contains a very simple example of using ERS.
15
* Basically, we use the custom issue defined in ExampleIssue.
16
*/
17
18
/** This function illustrates the usage of range checking macros.
19
* \param n an integer excepted to be between 0 and 42.
20
*/
21
22
void
foo
(
int
n
) {
23
ERS_RANGE_CHECK
( 0,
n
, 42 );
24
ERS_DEBUG_0
(
"function foo called with value %d"
,
n
);
25
}
// foo
26
27
void
massive_test
() {
28
ers::StreamFactory::set_stream
(
ers::debug_2
,
"null"
);
29
ERS_DEBUG_0
(
"dumping a lot of log issues"
);
30
for
(
int
i = 0; i < 1000000; i++ ) {
ERS_DEBUG_2
(
"dump %d"
, i ); }
// for
31
}
//
32
33
int
main
(
int
argc,
char
** argv ) {
34
for
(
int
i = 1; i < argc; i++ )
35
{
// we add all parameters as qualifiers
36
ers::Context::add_qualifier
( argv[i] );
37
}
//
38
ers::Context::add_qualifier
(
"ers_test"
);
// we add a qualifier to all issues
39
try
40
{
// We need to work with a try/catch block
41
massive_test
();
42
ers::StreamFactory::set_stream
(
43
ers::debug_3
,
44
"filter:?!ers_test,ers_failure@default"
);
// we filter out all issue with qualifier
45
// ers_test at level debug_3
46
ERS_DEBUG_3
(
"This should not be displayed"
);
47
ERS_DEBUG_0
(
"checking static assert"
);
48
ERS_STATIC_ASSERT
(
sizeof
(
int
) == 4 );
49
ERS_DEBUG_0
(
"dispatching custom issue to warning stream"
);
50
ExampleIssue
issue(
ERS_HERE
,
ers::warning
, 10 );
// we build an instance of our Issue
51
ers::StreamFactory::dispatch
( issue );
// dispatch sends it to the correct stream based on
52
// 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 "
56
"done by defining the N_DEBUG macro"
);
57
ERS_DEBUG_0
(
"throwing custom issue"
);
58
throw
ExampleIssue
(
ERS_HERE
,
ers::error
, 25 );
59
}
catch
(
ers::Issue
& e )
60
{
// we catch issues and send them to the warning stream
61
ers::StreamFactory::warning
( &e );
62
}
63
return
0;
64
}
// main
n
const Int_t n
Definition
DataBase/tau_mode.c:57
ERS_STATIC_ASSERT
#define ERS_STATIC_ASSERT(expr)
Definition
Event/ers/include/ers/Assertion.h:71
ERS_HERE
#define ERS_HERE
Definition
Event/ers/include/ers/Context.h:124
ERS_RANGE_CHECK
#define ERS_RANGE_CHECK(min, value, max)
Definition
Event/ers/include/ers/RangeIssue.h:38
ERS_DEBUG_0
#define ERS_DEBUG_0(...)
Definition
Event/ers/include/ers/StreamFactory.h:210
ERS_DEBUG_3
#define ERS_DEBUG_3(...)
Definition
Event/ers/include/ers/StreamFactory.h:263
ERS_DEBUG_2
#define ERS_DEBUG_2(...)
Definition
Event/ers/include/ers/StreamFactory.h:250
massive_test
void massive_test()
Definition
Event/ers/test/test.cxx:27
foo
void foo(int n)
Definition
Event/ers/test/test.cxx:22
ExampleIssue.h
ExampleIssue
Example issue.
Definition
ExampleIssue.h:19
ers::Context::add_qualifier
static void add_qualifier(const std::string &qualif)
Definition
Context.cxx:58
ers::Issue
Root Issue class.
Definition
Event/ers/include/ers/Issue.h:37
ers::StreamFactory::set_stream
static void set_stream(severity_t, const std::string &key)
Definition
StreamFactory.cxx:270
ers::StreamFactory::warning
Stream * warning()
Warning stream.
Definition
StreamFactory.cxx:333
ers::StreamFactory::dispatch
static void dispatch(Issue *i, bool throw_error=false)
Sends an issue to the appropriate stream according to its severity_t.
Definition
StreamFactory.cxx:257
ers::error
@ error
Definition
Event/ers/include/ers/Core.h:32
ers::warning
@ warning
Definition
Event/ers/include/ers/Core.h:31
ers::debug_2
@ debug_2
Definition
Event/ers/include/ers/Core.h:27
ers::debug_3
@ debug_3
Definition
Event/ers/include/ers/Core.h:28
main
int main()
Definition
phokhara.cc:42
8.0.0
BOSS_Source
Event
ers
test
test.cxx
Generated by
1.16.1