BOSS
7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/ers/ers-00-00-03/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
11
12
#include "
ers/ers.h
"
13
#include "
ExampleIssue.h
"
14
15
16
17
/** \file test.cxx
18
* This file contains a very simple example of using ERS.
19
* Basically, we use the custom issue defined in ExampleIssue.
20
*/
21
22
/** This function illustrates the usage of range checking macros.
23
* \param n an integer excepted to be between 0 and 42.
24
*/
25
26
void
foo
(
int
n
) {
27
ERS_RANGE_CHECK
(0,
n
,42) ;
28
ERS_DEBUG_0
(
"function foo called with value %d"
,
n
);
29
}
// foo
30
31
void
massive_test
() {
32
ers::StreamFactory::set_stream
(
ers::debug_2
,
"null"
);
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
}
//
38
39
int
main
(
int
argc,
char
** argv) {
40
for
(
int
i=1;i<argc;i++) {
// we add all parameters as qualifiers
41
ers::Context::add_qualifier
(argv[i]) ;
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"
);
57
throw
ExampleIssue
(
ERS_HERE
,
ers::error
,25);
58
}
catch
(
ers::Issue
&e) {
// we catch issues and send them to the warning stream
59
ers::StreamFactory::warning
(&e);
60
}
61
return
0 ;
62
}
// main
63
ERS_HERE
#define ERS_HERE
Definition:
Context.h:119
n
const Int_t n
Definition:
DataBase/tau_mode.c:65
ERS_STATIC_ASSERT
#define ERS_STATIC_ASSERT(expr)
Definition:
Event/ers/ers-00-00-03/ers/Assertion.h:69
massive_test
void massive_test()
Definition:
Event/ers/ers-00-00-03/test/test.cxx:31
foo
void foo(int n)
Definition:
Event/ers/ers-00-00-03/test/test.cxx:26
ExampleIssue.h
ERS_RANGE_CHECK
#define ERS_RANGE_CHECK(min, value, max)
Definition:
RangeIssue.h:34
ERS_DEBUG_0
#define ERS_DEBUG_0(...)
Definition:
StreamFactory.h:173
ERS_DEBUG_3
#define ERS_DEBUG_3(...)
Definition:
StreamFactory.h:199
ERS_DEBUG_2
#define ERS_DEBUG_2(...)
Definition:
StreamFactory.h:192
ExampleIssue
Example issue.
Definition:
ExampleIssue.h:20
ers::Context::add_qualifier
static void add_qualifier(const std::string &qualif)
Definition:
Context.cxx:56
ers::Issue
Root Issue class.
Definition:
ers/ers-00-00-03/ers/Issue.h:40
ers::StreamFactory::set_stream
static void set_stream(severity_t, const std::string &key)
Definition:
StreamFactory.cxx:269
ers::StreamFactory::warning
Stream * warning()
Warning stream.
Definition:
StreamFactory.cxx:338
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:254
ers.h
ers header and documentation file
ers::warning
@ warning
Definition:
Core.h:24
ers::error
@ error
Definition:
Core.h:24
ers::debug_3
@ debug_3
Definition:
Core.h:24
ers::debug_2
@ debug_2
Definition:
Core.h:24
main
int main()
Definition:
test_IFile.cxx:11
source
Event
ers
ers-00-00-03
test
test.cxx
Generated by
1.9.6