CMS 3D CMS Logo

ErrorObj.h
Go to the documentation of this file.
1 #ifndef MessageLogger_ErrorObj_h
2 #define MessageLogger_ErrorObj_h
3 
4 // ----------------------------------------------------------------------
5 //
6 // ErrorObj is the representation of all information about an error
7 // message. The system uses this heavily: ErrorLog forms an
8 // ErrorObj to pass around to destinations. A physicist is
9 // permitted to use ErrorObj to form a message for potential
10 // logging.
11 //
12 // 7/8/98 mf Created file.
13 // 6/15/99 mf,jvr Inserted operator<<(void (*f)(ErrorLog&)
14 // 7/16/99 jvr Added setSeverity() and setID functions
15 // 6/6/00 web Adapt to consolidated ELcout/X
16 // 6/14/00 web Declare classes before granting friendship.
17 // 5/7/01 mf operator<< (const char[]) to avoid many instantiations of
18 // the template one for each length of potential error message
19 // 6/5/01 mf Made set() and clear() public. Added setReactedTo.
20 // 6/6/06 mf verbatim.
21 //
22 // ----------------------------------------------------------------------
23 
27 
28 #include "fmt/format.h"
29 
30 #include <sstream>
31 #include <string>
32 
33 namespace edm {
34 
35  // ----------------------------------------------------------------------
36  // Prerequisite classes:
37  // ----------------------------------------------------------------------
38 
39  class ELcout;
40 
41  // ----------------------------------------------------------------------
42  // ErrorObj:
43  // ----------------------------------------------------------------------
44 
45  class ErrorObj {
46  public:
47  // --- birth/death:
48  //
49  ErrorObj(const messagelogger::ELseverityLevel& sev, std::string_view id, bool verbatim = false);
50  ErrorObj(const ErrorObj& orig); // Same serial number and everything!
51  virtual ~ErrorObj();
52 
54  void swap(ErrorObj& other);
55  // --- accessors:
56  //
57  int serial() const;
58  const ELextendedID& xid() const;
59  const std::string& idOverflow() const;
60  time_t timestamp() const;
61  const ELlist_string& items() const;
62  bool reactedTo() const;
63  std::string fullText() const;
64  const std::string& context() const;
65  bool is_verbatim() const;
66 
67  // mutators:
68  //
69  virtual void setSeverity(const messagelogger::ELseverityLevel& sev);
70  virtual void setID(std::string_view ID);
71  virtual void setModule(std::string_view module);
72  virtual void setSubroutine(std::string_view subroutine);
73  virtual void setContext(std::string_view context);
74 
75  // ----- Methods for ErrorLog or for physicists logging errors:
76  //
77  template <class T>
78  inline ErrorObj& opltlt(const T& t);
79  ErrorObj& opltlt(const char s[]);
80  inline ErrorObj& operator<<(std::ostream& (*f)(std::ostream&));
81  inline ErrorObj& operator<<(std::ios_base& (*f)(std::ios_base&));
82  template <typename... Args>
83  inline ErrorObj& format(fmt::format_string<Args...> format, Args&&... args);
84  inline ErrorObj& vformat(std::string_view fmt, fmt::format_args args);
85 
86  virtual ErrorObj& emitToken(std::string_view txt);
87 
88  // --- mutators for use by ELadministrator and ELtsErrorLog
89  //
90  virtual void set(const messagelogger::ELseverityLevel& sev, std::string_view id);
91  virtual void clear();
92  virtual void setReactedTo(bool r);
93 
94  private:
95  // --- data members:
96  //
97  int mySerial;
100  time_t myTimestamp;
104  std::ostringstream myOs;
106  bool verbatim;
107 
108  }; // ErrorObj
109 
110  // ----------------------------------------------------------------------
111 
112  // ----- Method for physicists logging errors:
113  //
114  template <class T>
115  inline ErrorObj& operator<<(ErrorObj& e, const T& t);
116 
117  ErrorObj& operator<<(ErrorObj& e, const char s[]);
118 
119  // ----------------------------------------------------------------------
120 
121  // ----------------------------------------------------------------------
122  // Global functions:
123  // ----------------------------------------------------------------------
124 
125  inline void swap(ErrorObj& a, ErrorObj& b) { a.swap(b); }
126 
127 } // end of namespace edm
128 
129 // ----------------------------------------------------------------------
130 // .icc
131 // ----------------------------------------------------------------------
132 
133 // The icc file contains the template for operator<< (ErrorObj&, T)
134 
135 #define ERROROBJ_ICC
136 #include "FWCore/MessageLogger/interface/ErrorObj.icc"
137 #undef ERROROBJ_ICC
138 
139 // ----------------------------------------------------------------------
140 
141 #endif // MessageLogger_ErrorObj_h
std::string emptyString
Definition: ErrorObj.h:105
time_t myTimestamp
Definition: ErrorObj.h:100
virtual ~ErrorObj()
Definition: ErrorObj.cc:109
virtual void clear()
Definition: ErrorObj.cc:228
virtual ErrorObj & emitToken(std::string_view txt)
Definition: ErrorObj.cc:192
time_t timestamp() const
Definition: ErrorObj.cc:144
int serial() const
Definition: ErrorObj.cc:141
std::string fullText() const
Definition: ErrorObj.cc:151
uint32_t ID
Definition: Definitions.h:24
void swap(ErrorObj &other)
Definition: ErrorObj.cc:122
const ELlist_string & items() const
Definition: ErrorObj.cc:145
virtual void setSeverity(const messagelogger::ELseverityLevel &sev)
Definition: ErrorObj.cc:162
bool reactedTo() const
Definition: ErrorObj.cc:146
std::list< std::string > ELlist_string
Definition: ELlist.h:33
ErrorObj & vformat(std::string_view fmt, fmt::format_args args)
ELlist_string myItems
Definition: ErrorObj.h:101
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
const std::string & context() const
Definition: ErrorObj.cc:149
virtual void setReactedTo(bool r)
Definition: ErrorObj.cc:186
std::string myContext
Definition: ErrorObj.h:103
ELextendedID myXid
Definition: ErrorObj.h:98
ErrorObj & opltlt(const T &t)
virtual void setSubroutine(std::string_view subroutine)
Definition: ErrorObj.cc:179
ErrorObj(const messagelogger::ELseverityLevel &sev, std::string_view id, bool verbatim=false)
Definition: ErrorObj.cc:83
ErrorObj & operator<<(std::ostream &(*f)(std::ostream &))
std::ostringstream myOs
Definition: ErrorObj.h:104
double f[11][100]
virtual void setModule(std::string_view module)
Definition: ErrorObj.cc:175
const ELextendedID & xid() const
Definition: ErrorObj.cc:142
const std::string & idOverflow() const
Definition: ErrorObj.cc:143
std::string myIdOverflow
Definition: ErrorObj.h:99
bool verbatim
Definition: ErrorObj.h:106
bool is_verbatim() const
Definition: ErrorObj.cc:147
ErrorObj & operator=(const ErrorObj &other)
Definition: ErrorObj.cc:116
double b
Definition: hdecay.h:120
virtual void setContext(std::string_view context)
Definition: ErrorObj.cc:177
HLT enums.
double a
Definition: hdecay.h:121
virtual void setID(std::string_view ID)
Definition: ErrorObj.cc:169
ErrorObj & format(fmt::format_string< Args... > format, Args &&... args)
bool myReactedTo
Definition: ErrorObj.h:102
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger table.
long double T
int mySerial
Definition: ErrorObj.h:97