| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

StatusCode.cpp
Go to the documentation of this file.
1 #define GAUDIKERNEL_STATUSCODE_CPP 1
2
3 #include "GaudiKernel/StatusCode.h"
4 #include "GaudiKernel/Bootstrap.h"
5 #include "GaudiKernel/IMessageSvc.h"
6 #include "GaudiKernel/IStatusCodeSvc.h"
7 #include "GaudiKernel/ISvcLocator.h"
8 #include "GaudiKernel/IssueSeverity.h"
9 #include "GaudiKernel/MsgStream.h"
10 #include "GaudiKernel/System.h"
11 #include <exception>
12 #include <fstream>
13 #include <iostream>
14 #include <sstream>
15 #include <stdlib.h>
16
17 bool StatusCode::s_checking( false );
18
19 void StatusCode::enableChecking() { s_checking = true; }
20
21 void StatusCode::disableChecking() { s_checking = false; }
22
23 bool StatusCode::checkingEnabled() { return s_checking; }
24
25 const IssueSeverity& StatusCode::severity() const
26 {
27 static const IssueSeverity dummy;
28 return m_severity ? *m_severity : dummy;
29 }
30
31 void StatusCode::check()
32 {
33
34 if ( !m_checked && !GaudiException::s_proc && !std::uncaught_exception() ) {
35
36 auto msg = Gaudi::svcLocator()->as<IMessageSvc>();
37 auto scs = Gaudi::svcLocator()->service<IStatusCodeSvc>( "StatusCodeSvc" );
38
39 const size_t depth = 21;
40 void* addresses[depth];
41
42 std::string lib, fnc;
43 void* addr = nullptr;
45 if ( System::backTrace( addresses, depth ) ) {
46
47 for ( size_t idx : {2, 3} ) {
48 if ( System::getStackLevel( addresses[idx], addr, fnc, lib ) && fnc != "StatusCode::~StatusCode()" ) {
49
50 if ( scs ) {
51 scs->regFnc( fnc, lib );
52 } else {
53 MsgStream log( msg, "StatusCode" );
54 log << MSG::WARNING << "Unchecked in " << fnc << " (" << lib << ")" << endmsg;
55 }
56 break;
57 }
58 }
59 }
60 }
61 }
System.h
StatusCode::severity
GAUDI_API const IssueSeverity & severity() const
Severity.
Definition: StatusCode.cpp:25
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
IssueSeverity
Definition: IssueSeverity.h:23
StatusCode::check
void check()
Definition: StatusCode.cpp:31
MsgStream.h
System::getStackLevel
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
GaudiException::s_proc
static bool s_proc
"previous" element in the linked list
Definition: GaudiException.h:178
Bootstrap.h
StatusCode::enableChecking
static GAUDI_API void enableChecking()
Definition: StatusCode.cpp:19
ISvcLocator::as
SmartIF< IFace > as()
Definition: ISvcLocator.h:109
StatusCode::checkingEnabled
static GAUDI_API bool checkingEnabled()
Definition: StatusCode.cpp:23
System::backTrace
GAUDI_API int backTrace(void **addresses, const int depth)
IStatusCodeSvc.h
std::string
STL class.
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
IssueSeverity.h
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
StatusCode::s_checking
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:186
IMessageSvc.h
std::uncaught_exception
T uncaught_exception(T...args)
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
StatusCode::disableChecking
static GAUDI_API void disableChecking()
Definition: StatusCode.cpp:21
MSG::WARNING
Definition: IMessageSvc.h:16
StatusCode.h
IStatusCodeSvc
Definition: IStatusCodeSvc.h:7
ISvcLocator.h
StatusCode::m_severity
std::shared_ptr< const IssueSeverity > m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:184
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13