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 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 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 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
edm::ErrorObj::setReactedTo
virtual void setReactedTo(bool r)
Definition: ErrorObj.cc:184
writedatasetfile.args
args
Definition: writedatasetfile.py:18
edm::ErrorObj::serial
int serial() const
Definition: ErrorObj.cc:141
edm::ErrorObj::set
virtual void set(const ELseverityLevel &sev, std::string_view id)
Definition: ErrorObj.cc:215
edm::ErrorObj::context
const std::string & context() const
Definition: ErrorObj.cc:149
edm::ErrorObj::emitToken
virtual ErrorObj & emitToken(std::string_view txt)
Definition: ErrorObj.cc:190
ELlist.h
edm::ErrorObj::reactedTo
bool reactedTo() const
Definition: ErrorObj.cc:146
edm::ErrorObj::mySerial
int mySerial
Definition: ErrorObj.h:94
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
edm::ErrorObj::myIdOverflow
std::string myIdOverflow
Definition: ErrorObj.h:96
ELextendedID.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ErrorObj
Definition: ErrorObj.h:43
edm::swap
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
edm::ELextendedID
Definition: ELextendedID.h:25
edm::ErrorObj::myItems
ELlist_string myItems
Definition: ErrorObj.h:98
edm::ErrorObj::format
ErrorObj & format(std::string_view fmt, Args const &... args)
edm::ELlist_string
std::list< std::string > ELlist_string
Definition: ELlist.h:33
edm::ErrorObj::myContext
std::string myContext
Definition: ErrorObj.h:100
edm::operator<<
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
Definition: HLTGlobalStatus.h:106
edm::ErrorObj::fullText
std::string fullText() const
Definition: ErrorObj.cc:151
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::ErrorObj::timestamp
time_t timestamp() const
Definition: ErrorObj.cc:144
edm::ErrorObj::setSeverity
virtual void setSeverity(const ELseverityLevel &sev)
Definition: ErrorObj.cc:162
trackingPlots.other
other
Definition: trackingPlots.py:1467
edm::ErrorObj::setID
virtual void setID(std::string_view ID)
Definition: ErrorObj.cc:167
b
double b
Definition: hdecay.h:118
edm::ErrorObj::xid
const ELextendedID & xid() const
Definition: ErrorObj.cc:142
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ErrorObj::idOverflow
const std::string & idOverflow() const
Definition: ErrorObj.cc:143
a
double a
Definition: hdecay.h:119
align::ID
uint32_t ID
Definition: Definitions.h:24
edm::ErrorObj::ErrorObj
ErrorObj(const ELseverityLevel &sev, std::string_view id, bool verbatim=false)
Definition: ErrorObj.cc:83
edm::ErrorObj::items
const ELlist_string & items() const
Definition: ErrorObj.cc:145
edm::ErrorObj::myReactedTo
bool myReactedTo
Definition: ErrorObj.h:99
edm::ErrorObj::clear
virtual void clear()
Definition: ErrorObj.cc:226
edm::ErrorObj::emptyString
std::string emptyString
Definition: ErrorObj.h:102
ELseverityLevel.h
edm::ErrorObj::myXid
ELextendedID myXid
Definition: ErrorObj.h:95
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::ErrorObj::operator=
ErrorObj & operator=(const ErrorObj &other)
Definition: ErrorObj.cc:116
edm::ErrorObj::myOs
std::ostringstream myOs
Definition: ErrorObj.h:101
edm::ErrorObj::setContext
virtual void setContext(std::string_view context)
Definition: ErrorObj.cc:175
edm::ELseverityLevel
Definition: ELseverityLevel.h:26
edm::ErrorObj::verbatim
bool verbatim
Definition: ErrorObj.h:103
T
long double T
Definition: Basic3DVectorLD.h:48
edm::ErrorObj::myTimestamp
time_t myTimestamp
Definition: ErrorObj.h:97
edm::ErrorObj::~ErrorObj
virtual ~ErrorObj()
Definition: ErrorObj.cc:109
edm::ErrorObj::swap
void swap(ErrorObj &other)
Definition: ErrorObj.cc:122
edm::ErrorObj::setModule
virtual void setModule(std::string_view module)
Definition: ErrorObj.cc:173
edm::ErrorObj::opltlt
ErrorObj & opltlt(const T &t)
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::ErrorObj::setSubroutine
virtual void setSubroutine(std::string_view subroutine)
Definition: ErrorObj.cc:177
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:147