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