The Gaudi Framework  v29r0 (ff2e7097)
StatusCode.cpp
Go to the documentation of this file.
1 #define GAUDIKERNEL_STATUSCODE_CPP 1
2 
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 
20 
22 
24 
26 {
27  static const IssueSeverity dummy;
28  return m_severity ? *m_severity : dummy;
29 }
30 
32 {
33 
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 }
GAUDI_API const IssueSeverity & severity() const
Severity.
Definition: StatusCode.cpp:25
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
void check()
Definition: StatusCode.cpp:31
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:183
static bool s_proc
"previous" element in the linked list
static GAUDI_API void enableChecking()
Definition: StatusCode.cpp:19
SmartIF< IFace > as()
Definition: ISvcLocator.h:109
static GAUDI_API bool checkingEnabled()
Definition: StatusCode.cpp:23
GAUDI_API int backTrace(void **addresses, const int depth)
STL class.
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_API ISvcLocator * svcLocator()
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:186
T uncaught_exception(T...args)
static GAUDI_API void disableChecking()
Definition: StatusCode.cpp:21
std::shared_ptr< const IssueSeverity > m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:184
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209