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 <sstream>
29 #include <string>
30 
31 namespace edm {
32 
33  // ----------------------------------------------------------------------
34  // Prerequisite classes:
35  // ----------------------------------------------------------------------
36 
37  class ELcout;
38 
39  // ----------------------------------------------------------------------
40  // ErrorObj:
41  // ----------------------------------------------------------------------
42 
43  class ErrorObj {
44  public:
45  // --- birth/death:
46  //
47  ErrorObj(const messagelogger::ELseverityLevel& sev, std::string_view id, bool verbatim = false);
48  ErrorObj(const ErrorObj& orig); // Same serial number and everything!
49  virtual ~ErrorObj();
50 
52  void swap(ErrorObj& other);
53  // --- accessors:
54  //
55  int serial() const;
56  const ELextendedID& xid() const;
57  const std::string& idOverflow() const;
58  time_t timestamp() const;
59  const ELlist_string& items() const;
60  bool reactedTo() const;
61  std::string fullText() const;
62  const std::string& context() const;
63  bool is_verbatim() const;
64 
65  // mutators:
66  //
67  virtual void setSeverity(const messagelogger::ELseverityLevel& sev);
68  virtual void setID(std::string_view ID);
69  virtual void setModule(std::string_view module);
70  virtual void setSubroutine(std::string_view subroutine);
71  virtual void setContext(std::string_view context);
72 
73  // ----- Methods for ErrorLog or for physicists logging errors:
74  //
75  template <class T>
76  inline ErrorObj& opltlt(const T& t);
77  ErrorObj& opltlt(const char s[]);
78  inline ErrorObj& operator<<(std::ostream& (*f)(std::ostream&));
79  inline ErrorObj& operator<<(std::ios_base& (*f)(std::ios_base&));
80  template <typename... Args>
81  inline ErrorObj& format(std::string_view fmt, Args const&... args);
82 
83  virtual ErrorObj& emitToken(std::string_view txt);
84 
85  // --- mutators for use by ELadministrator and ELtsErrorLog
86  //
87  virtual void set(const messagelogger::ELseverityLevel& sev, std::string_view id);
88  virtual void clear();
89  virtual void setReactedTo(bool r);
90 
91  private:
92  // --- data members:
93  //
94  int mySerial;
97  time_t myTimestamp;
101  std::ostringstream myOs;
103  bool verbatim;
104 
105  }; // ErrorObj
106 
107  // ----------------------------------------------------------------------
108 
109  // ----- Method for physicists logging errors:
110  //
111  template <class T>
112  inline ErrorObj& operator<<(ErrorObj& e, const T& t);
113 
114  ErrorObj& operator<<(ErrorObj& e, const char s[]);
115 
116  // ----------------------------------------------------------------------
117 
118  // ----------------------------------------------------------------------
119  // Global functions:
120  // ----------------------------------------------------------------------
121 
122  inline void swap(ErrorObj& a, ErrorObj& b) { a.swap(b); }
123 
124 } // end of namespace edm
125 
126 // ----------------------------------------------------------------------
127 // .icc
128 // ----------------------------------------------------------------------
129 
130 // The icc file contains the template for operator<< (ErrorObj&, T)
131 
132 #define ERROROBJ_ICC
133 #include "FWCore/MessageLogger/interface/ErrorObj.icc"
134 #undef ERROROBJ_ICC
135 
136 // ----------------------------------------------------------------------
137 
138 #endif // MessageLogger_ErrorObj_h
std::string emptyString
Definition: ErrorObj.h:102
time_t myTimestamp
Definition: ErrorObj.h:97
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
ELlist_string myItems
Definition: ErrorObj.h:98
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
const std::string & context() const
Definition: ErrorObj.cc:149
ErrorObj & format(std::string_view fmt, Args const &... args)
virtual void setReactedTo(bool r)
Definition: ErrorObj.cc:186
std::string myContext
Definition: ErrorObj.h:100
ELextendedID myXid
Definition: ErrorObj.h:95
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:101
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:96
bool verbatim
Definition: ErrorObj.h:103
bool is_verbatim() const
Definition: ErrorObj.cc:147
ErrorObj & operator=(const ErrorObj &other)
Definition: ErrorObj.cc:116
double b
Definition: hdecay.h:118
virtual void setContext(std::string_view context)
Definition: ErrorObj.cc:177
HLT enums.
double a
Definition: hdecay.h:119
virtual void setID(std::string_view ID)
Definition: ErrorObj.cc:169
bool myReactedTo
Definition: ErrorObj.h:99
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger table.
long double T
int mySerial
Definition: ErrorObj.h:94