IssueSeverity.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_ISSUESEVERITY_H
2 #define GAUDIKERNEL_ISSUESEVERITY_H 1
3 
4 class StatusCode;
5 
6 #include <string>
7 #include <map>
8 #include <iostream>
9 
10 #include "GaudiKernel/Kernel.h"
11 
12 #define ISSUE(x,y) IssueSeverity(x,__LINE__,__FILE__,y)
13 #define STATUSCODE(z,x,y) StatusCode(z,ISSUE(x,y))
14 
15 class IIssueLogger;
16 
17 // namespace IS {
18 // enum Level {
19 // NIL = 0,
20 // VERBOSE,
21 // DEBUG,
22 // DEBUG1,
23 // DEBUG2,
24 // DEBUG3,
25 // INFO,
26 // WARNING,
27 // RECOVERABLE,
28 // ERROR,
29 // FATAL,
30 // ALWAYS,
31 // NUM_LEVELS
32 // };
33 // }
34 
35 
36 #ifdef _WIN32
37 #ifdef ERROR
38 #undef ERROR
39 #endif
40 #endif
41 
42 class GAUDI_API IssueSeverity final {
43 
44 public:
45 
46  enum Level {
47  NIL = 0,
48  VERBOSE,
49  DEBUG,
50  DEBUG1,
51  DEBUG2,
52  DEBUG3,
53  INFO,
54  WARNING,
55  RECOVERABLE,
56  ERROR,
57  FATAL,
58  ALWAYS,
60  };
61 
62  IssueSeverity() = default;
64  std::string file,
65  std::string msg="");
66  IssueSeverity( IssueSeverity::Level level, std::string msg="");
67 
68  IssueSeverity( const IssueSeverity& ) = delete;
69  IssueSeverity& operator=( const IssueSeverity& ) = delete;
70  IssueSeverity( IssueSeverity&& ) noexcept;
71  IssueSeverity& operator=(IssueSeverity&& ) noexcept;
72 
73  ~IssueSeverity();
74 
75  void setLevel(const IssueSeverity::Level& l) {
76  m_level = l;
77  }
78  void setMsg(std::string m) {
79  m_msg = std::move(m);
80  }
81 
82  IssueSeverity::Level getLevel() const { return m_level; }
83  std::string getMsg() const { return m_msg; }
84  std::string getOrigin() const;
85 
86  void report();
87 
88  friend inline std::ostream& operator<< ( std::ostream&,
89  const IssueSeverity& ) ;
90 
91 private:
92 
93  std::string m_file;
94  std::string m_msg;
95 
96  int m_line = 0;
98  bool m_reported = true;
99 
100  static bool m_init;
101  static IIssueLogger* m_ers;
102 
103 
104 };
105 
106 
108  std::string file,
109  std::string msg):
110  m_file(std::move(file)),m_msg(std::move(msg)), m_line(line), m_level(level), m_reported(false) {
111  report();
112 }
113 
115  IssueSeverity(std::move(level),0,"??",std::move(msg)) { }
116 
117 inline IssueSeverity::IssueSeverity( IssueSeverity&& rhs ) noexcept {
118  m_file = std::move(rhs.m_file);
119  m_msg = std::move(rhs.m_msg);
120  m_line = rhs.m_line;
121  m_level = rhs.m_level;
122  m_reported = rhs.m_reported;
123  rhs.m_reported = true;
124 }
125 
126 inline IssueSeverity& IssueSeverity::operator=(IssueSeverity&& rhs) noexcept {
127  m_file = rhs.m_file;
128  m_msg = rhs.m_level;
129  m_line = rhs.m_line;
130  m_level = rhs.m_level;
131  m_reported = rhs.m_reported;
132  rhs.m_reported = true;
133  return *this;
134 }
135 
136 std::ostream& operator<< ( std::ostream& os , const IssueSeverity& rhs ) {
137  os << "ISSUE: level " << rhs.getLevel() << " from: " << rhs.getOrigin()
138  << " msg: " << rhs.getMsg();
139  return os;
140 }
141 
142 
143 #endif
std::string getOrigin() const
#define GAUDI_API
Definition: Kernel.h:107
std::ostream & operator<<(std::ostream &os, const IssueSeverity &rhs)
STL namespace.
std::string m_file
Definition: IssueSeverity.h:93
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
constexpr double m
Definition: SystemOfUnits.h:93
std::string m_msg
Definition: IssueSeverity.h:94
IssueSeverity::Level m_level
Definition: IssueSeverity.h:97
list file
Definition: ana.py:160
dictionary l
Definition: gaudirun.py:422
IssueSeverity & operator=(const IssueSeverity &)=delete
IssueSeverity()=default
IssueSeverity::Level getLevel() const
Definition: IssueSeverity.h:82
std::string getMsg() const
Definition: IssueSeverity.h:83
int line
Definition: ana.py:50