All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IssueSeverity.cpp
Go to the documentation of this file.
1 #define GAUDIKERNEL_ISSUESEVERITY_CPP 1
2 
6 #include "GaudiKernel/System.h"
9 
10 #include <sstream>
11 
12 bool IssueSeverity::m_init(false);
14 
16  if (!m_init) {
17  m_init = true;
18  m_ers = Gaudi::svcLocator()->service<IIssueLogger>("IssueLogger").get();
19  }
20 }
21 
23 
24  if (!m_reported) {
25  report();
26  // do stuff
27  }
28 
29 }
30 
31 void
33 
34  if (m_ers != 0) {
35  m_ers->report(this);
36  } else {
37  std::cerr << *this << std::endl;
38  }
39  m_reported = true;
40 
41 }
42 
43 
44 std::string
46  std::ostringstream ost;
47  ost << m_file << ":" << m_line;
48  return ost.str();
49 }
50 
51 IssueSeverity::operator StatusCode() const {
52  if (m_level == IssueSeverity::RECOVERABLE) {
53  return StatusCode(StatusCode::RECOVERABLE, *this);
54  } else if (m_level < IssueSeverity::ERROR) {
55  return StatusCode(StatusCode::SUCCESS, *this);
56  } else {
57  return StatusCode(StatusCode::FAILURE, *this);
58  }
59 }
static bool m_init
Definition: IssueSeverity.h:98
static IIssueLogger * m_ers
Definition: IssueSeverity.h:99
static void init()
std::string getOrigin() const
virtual void report(IssueSeverity::Level level, const std::string &msg, const std::string &origin)=0
std::string m_file
Definition: IssueSeverity.h:96
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:82
GAUDI_API ISvcLocator * svcLocator()
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30