LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
mf::ErrorObj Class Reference

#include "ErrorObj.h"

Public Member Functions

virtual ~ErrorObj ()
 
 ErrorObj ()=delete
 
 ErrorObj (ELseverityLevel const sev, std::string const &category, bool verbatim=false, std::string const &filename="", int lineNumber=0)
 
 ErrorObj (ErrorObj const &)
 
int serial () const
 
ELextendedID const & xid () const
 
std::string const & idOverflow () const
 
timeval timestamp () const
 
std::list< std::string > const & items () const
 
bool reactedTo () const
 
std::string fullText () const
 
std::string const & context () const
 
std::string const & iteration () const
 
bool is_verbatim () const
 
std::string const & filename () const
 
int lineNumber () const
 
virtual void setTimestamp (timeval const &)
 
virtual void setContext (std::string const &)
 
virtual void setIteration (std::string const &)
 
virtual void setSeverity (ELseverityLevel const)
 
virtual void setID (std::string const &)
 
virtual void setModule (std::string const &)
 
virtual void setSubroutine (std::string const &)
 
virtual void setHostName (std::string const &)
 
virtual void setHostAddr (std::string const &)
 
virtual void setApplication (std::string const &)
 
virtual void setPID (long)
 
ErrorObjoperator<< (std::ostream &(*f)(std::ostream &))
 
ErrorObjoperator<< (std::ios_base &(*f)(std::ios_base &))
 
ErrorObjopltlt (char const *)
 
template<class T >
ErrorObjopltlt (T const &)
 
virtual ErrorObjeo_emit (std::string const &)
 
virtual void clear ()
 
virtual void set (ELseverityLevel const, std::string const &id)
 
virtual void setReactedTo (bool)
 

Private Attributes

int serial_ {}
 
ELextendedID xid_ {}
 
std::string idOverflow_ {}
 
timeval timestamp_ {0, 0}
 
std::list< std::string > items_ {}
 
bool reactedTo_ {false}
 
std::string iteration_ {}
 
std::ostringstream oss_ {}
 
bool verbatim_ {false}
 
std::string filename_ {}
 
int lineNumber_ {}
 

Detailed Description

Definition at line 17 of file ErrorObj.h.

Constructor & Destructor Documentation

mf::ErrorObj::~ErrorObj ( )
virtual

Definition at line 20 of file ErrorObj.cc.

20 {}
mf::ErrorObj::ErrorObj ( )
delete
mf::ErrorObj::ErrorObj ( ELseverityLevel const  sev,
std::string const &  category,
bool  verbatim = false,
std::string const &  filename = "",
int  lineNumber = 0 
)

Definition at line 22 of file ErrorObj.cc.

References filename(), filename_, idOverflow_, items_, iteration_, lineNumber(), lineNumber_, oss_, reactedTo_, timestamp_, verbatim_, and xid_.

27  : serial_{}
28  , xid_{}
29  , idOverflow_{}
30  , timestamp_{0, 0}
31  , items_{}
32  , reactedTo_{false}
33  , iteration_{}
34  , oss_{}
35  , verbatim_{verbatim}
38  {
39  set(sev, category);
40  }
int lineNumber() const
Definition: ErrorObj.cc:126
bool verbatim_
Definition: ErrorObj.h:88
timeval timestamp_
Definition: ErrorObj.h:83
std::string idOverflow_
Definition: ErrorObj.h:82
std::string filename_
Definition: ErrorObj.h:89
int serial_
Definition: ErrorObj.h:80
int lineNumber_
Definition: ErrorObj.h:90
bool reactedTo_
Definition: ErrorObj.h:85
std::string const & filename() const
Definition: ErrorObj.cc:120
ELextendedID xid_
Definition: ErrorObj.h:81
std::string iteration_
Definition: ErrorObj.h:86
std::ostringstream oss_
Definition: ErrorObj.h:87
std::list< std::string > items_
Definition: ErrorObj.h:84
mf::ErrorObj::ErrorObj ( ErrorObj const &  orig)

Definition at line 42 of file ErrorObj.cc.

References filename_, idOverflow_, items_, lineNumber_, reactedTo_, serial_, timestamp_, verbatim_, and xid_.

43  : serial_{orig.serial_}
44  , xid_(orig.xid_)
45  , idOverflow_{orig.idOverflow_}
46  , timestamp_(orig.timestamp_)
47  , items_{orig.items_}
48  , reactedTo_{orig.reactedTo_}
49  , verbatim_{orig.verbatim_}
50  , filename_{orig.filename_}
51  , lineNumber_{orig.lineNumber_}
52  {}
bool verbatim_
Definition: ErrorObj.h:88
timeval timestamp_
Definition: ErrorObj.h:83
std::string idOverflow_
Definition: ErrorObj.h:82
std::string filename_
Definition: ErrorObj.h:89
int serial_
Definition: ErrorObj.h:80
int lineNumber_
Definition: ErrorObj.h:90
bool reactedTo_
Definition: ErrorObj.h:85
ELextendedID xid_
Definition: ErrorObj.h:81
std::list< std::string > items_
Definition: ErrorObj.h:84

Member Function Documentation

void mf::ErrorObj::clear ( )
virtual

Definition at line 218 of file ErrorObj.cc.

References idOverflow_, items_, iteration_, oss_, reactedTo_, serial_, timestamp_, verbatim_, and xid_.

219  {
220  serial_ = 0;
221  xid_ = {};
222  idOverflow_.clear();
223  timestamp_ = {0, 0};
224  items_.clear();
225  reactedTo_ = false;
226  iteration_.clear();
227  oss_.str({});
228  verbatim_ = false;
229  }
bool verbatim_
Definition: ErrorObj.h:88
timeval timestamp_
Definition: ErrorObj.h:83
std::string idOverflow_
Definition: ErrorObj.h:82
int serial_
Definition: ErrorObj.h:80
bool reactedTo_
Definition: ErrorObj.h:85
ELextendedID xid_
Definition: ErrorObj.h:81
std::string iteration_
Definition: ErrorObj.h:86
std::ostringstream oss_
Definition: ErrorObj.h:87
std::list< std::string > items_
Definition: ErrorObj.h:84
string const & mf::ErrorObj::context ( ) const

Definition at line 98 of file ErrorObj.cc.

References iteration_.

Referenced by mf::service::ELdestination::fillPrefix(), mf::service::ELstatistics::log(), and mf::service::ELdestination::log().

99  {
100  return iteration_;
101  }
std::string iteration_
Definition: ErrorObj.h:86
ErrorObj & mf::ErrorObj::eo_emit ( std::string const &  s)
virtual

Definition at line 207 of file ErrorObj.cc.

References items_, and setSubroutine().

Referenced by opltlt().

208  {
209  if (s.substr(0, 5) == "@SUB=") {
210  setSubroutine(s.substr(5));
211  } else {
212  items_.push_back(s);
213  }
214  return *this;
215  }
virtual void setSubroutine(std::string const &)
Definition: ErrorObj.cc:170
std::list< std::string > items_
Definition: ErrorObj.h:84
string const & mf::ErrorObj::filename ( ) const

Definition at line 120 of file ErrorObj.cc.

References filename_.

Referenced by ErrorObj(), and mf::service::ELdestination::fillUsrMsg().

121  {
122  return filename_;
123  }
std::string filename_
Definition: ErrorObj.h:89
string mf::ErrorObj::fullText ( ) const

Definition at line 110 of file ErrorObj.cc.

References items_.

Referenced by mf::LogErrorObj().

111  {
112  string result;
113  for (auto const& text : items_) {
114  result += text;
115  }
116  return result;
117  }
std::list< std::string > items_
Definition: ErrorObj.h:84
string const & mf::ErrorObj::idOverflow ( ) const

Definition at line 67 of file ErrorObj.cc.

References idOverflow_.

Referenced by mf::service::ELdestination::fillPrefix(), and mf::LogErrorObj().

68  {
69  return idOverflow_;
70  }
std::string idOverflow_
Definition: ErrorObj.h:82
bool mf::ErrorObj::is_verbatim ( ) const
std::list< std::string > const & mf::ErrorObj::items ( ) const

Definition at line 79 of file ErrorObj.cc.

References items_.

Referenced by mf::service::ELdestination::fillUsrMsg().

80  {
81  return items_;
82  }
std::list< std::string > items_
Definition: ErrorObj.h:84
string const & mf::ErrorObj::iteration ( ) const

Definition at line 104 of file ErrorObj.cc.

References iteration_.

105  {
106  return iteration_;
107  }
std::string iteration_
Definition: ErrorObj.h:86
int mf::ErrorObj::lineNumber ( ) const

Definition at line 126 of file ErrorObj.cc.

References lineNumber_.

Referenced by ErrorObj(), and mf::service::ELdestination::fillUsrMsg().

127  {
128  return lineNumber_;
129  }
int lineNumber_
Definition: ErrorObj.h:90
ErrorObj & mf::ErrorObj::operator<< ( std::ostream &(*)(std::ostream &)  f)

Definition at line 247 of file ErrorObj.cc.

References f, and oss_.

Referenced by opltlt().

248  {
249  f(oss_);
250  oss_.str({});
251  return *this;
252  }
TFile f
Definition: plotHisto.C:6
std::ostringstream oss_
Definition: ErrorObj.h:87
ErrorObj & mf::ErrorObj::operator<< ( std::ios_base &(*)(std::ios_base &)  f)

Definition at line 255 of file ErrorObj.cc.

References f, and oss_.

256  {
257  f(oss_);
258  return *this;
259  }
TFile f
Definition: plotHisto.C:6
std::ostringstream oss_
Definition: ErrorObj.h:87
ErrorObj & mf::ErrorObj::opltlt ( char const *  s)

Definition at line 263 of file ErrorObj.cc.

References eo_emit(), and oss_.

Referenced by mf::operator<<().

264  {
265  oss_.str({});
266  oss_ << s;
267  if (!oss_.str().empty()) {
268  eo_emit(oss_.str());
269  }
270  return *this;
271  }
virtual ErrorObj & eo_emit(std::string const &)
Definition: ErrorObj.cc:207
std::ostringstream oss_
Definition: ErrorObj.h:87
template<class T >
ErrorObj & mf::ErrorObj::opltlt ( T const &  t)

Definition at line 95 of file ErrorObj.h.

References e, eo_emit(), operator<<(), and oss_.

96  {
97  oss_.str({});
98  oss_ << t;
99  if (!oss_.str().empty()) {
100  eo_emit(oss_.str());
101  }
102  return *this;
103  }
virtual ErrorObj & eo_emit(std::string const &)
Definition: ErrorObj.cc:207
std::ostringstream oss_
Definition: ErrorObj.h:87
bool mf::ErrorObj::reactedTo ( ) const

Definition at line 85 of file ErrorObj.cc.

References reactedTo_.

86  {
87  return reactedTo_;
88  }
bool reactedTo_
Definition: ErrorObj.h:85
int mf::ErrorObj::serial ( ) const

Definition at line 55 of file ErrorObj.cc.

References serial_.

Referenced by mf::service::ELdestination::fillPrefix().

56  {
57  return serial_;
58  }
int serial_
Definition: ErrorObj.h:80
void mf::ErrorObj::set ( ELseverityLevel const  sev,
std::string const &  id 
)
virtual

Definition at line 232 of file ErrorObj.cc.

References mf::ourSerial, serial_, setID(), setSeverity(), and timestamp_.

233  {
234  gettimeofday(&timestamp_, 0);
235  serial_ = ++ourSerial;
236  setID(category);
237  setSeverity(sev);
238  }
virtual void setID(std::string const &)
Definition: ErrorObj.cc:141
timeval timestamp_
Definition: ErrorObj.h:83
static atomic< int > ourSerial
Definition: ErrorObj.cc:18
int serial_
Definition: ErrorObj.h:80
virtual void setSeverity(ELseverityLevel const)
Definition: ErrorObj.cc:132
void mf::ErrorObj::setApplication ( std::string const &  application)
virtual

Definition at line 195 of file ErrorObj.cc.

References mf::ELextendedID::setApplication(), and xid_.

196  {
197  xid_.setApplication(application);
198  }
ELextendedID xid_
Definition: ErrorObj.h:81
void setApplication(std::string const &application)
void mf::ErrorObj::setContext ( std::string const &  s)
virtual

Definition at line 158 of file ErrorObj.cc.

References iteration_.

159  {
160  iteration_ = s;
161  }
std::string iteration_
Definition: ErrorObj.h:86
void mf::ErrorObj::setHostAddr ( std::string const &  hostaddr)
virtual

Definition at line 189 of file ErrorObj.cc.

References mf::ELextendedID::setHostaddr(), and xid_.

190  {
191  xid_.setHostaddr(hostaddr);
192  }
void setHostaddr(std::string const &hostaddr)
ELextendedID xid_
Definition: ErrorObj.h:81
void mf::ErrorObj::setHostName ( std::string const &  hostname)
virtual

Definition at line 183 of file ErrorObj.cc.

References mf::ELextendedID::setHostname(), and xid_.

184  {
185  xid_.setHostname(hostname);
186  }
void setHostname(std::string const &hostname)
Definition: ELextendedID.cc:99
ELextendedID xid_
Definition: ErrorObj.h:81
void mf::ErrorObj::setID ( std::string const &  category)
virtual

Definition at line 141 of file ErrorObj.cc.

References idOverflow_, mf::ELextendedID::setID(), and xid_.

Referenced by set().

142  {
143  xid_.setID(string(category, 0, maxCategoryLength));
144  if (category.length() > maxCategoryLength) {
145  idOverflow_ = string(
146  category, maxCategoryLength, category.length() - maxCategoryLength);
147  }
148  }
std::string idOverflow_
Definition: ErrorObj.h:82
ELextendedID xid_
Definition: ErrorObj.h:81
void setID(std::string const &id)
Definition: ELextendedID.cc:75
void mf::ErrorObj::setIteration ( std::string const &  s)
virtual

Definition at line 164 of file ErrorObj.cc.

References iteration_.

165  {
166  iteration_ = s;
167  }
std::string iteration_
Definition: ErrorObj.h:86
void mf::ErrorObj::setModule ( std::string const &  module)
virtual

Definition at line 151 of file ErrorObj.cc.

References mf::ELextendedID::setModule(), and xid_.

152  {
153  xid_.setModule(module);
154  }
ELextendedID xid_
Definition: ErrorObj.h:81
void setModule(std::string const &module)
Definition: ELextendedID.cc:87
void mf::ErrorObj::setPID ( long  pid)
virtual

Definition at line 201 of file ErrorObj.cc.

References mf::ELextendedID::setPID(), and xid_.

202  {
203  xid_.setPID(pid);
204  }
ELextendedID xid_
Definition: ErrorObj.h:81
void setPID(long pid)
void mf::ErrorObj::setReactedTo ( bool  r)
virtual

Definition at line 177 of file ErrorObj.cc.

References r, and reactedTo_.

Referenced by mf::service::ELstatistics::log(), and mf::service::ELdestination::log().

178  {
179  reactedTo_ = r;
180  }
TRandom r
Definition: spectrum.C:23
bool reactedTo_
Definition: ErrorObj.h:85
void mf::ErrorObj::setSeverity ( ELseverityLevel const  sev)
virtual

Definition at line 132 of file ErrorObj.cc.

References mf::ELdebug, mf::ELhighestSeverity, mf::ELsevere, mf::ELzeroSeverity, mf::ELextendedID::setSeverity(), and xid_.

Referenced by set().

133  {
135  (sev <= ELzeroSeverity) ?
136  (ELseverityLevel)ELdebug :
137  ((sev >= ELhighestSeverity) ? (ELseverityLevel)ELsevere : sev));
138  }
void setSeverity(ELseverityLevel severity)
Definition: ELextendedID.cc:81
ELslProxy< ELhighestSeverityGen > constexpr ELhighestSeverity
ELslProxy< ELzeroSeverityGen > constexpr ELzeroSeverity
ELextendedID xid_
Definition: ErrorObj.h:81
ELslProxy< ELdebugGen > constexpr ELdebug
ELslProxy< ELsevereGen > constexpr ELsevere
void mf::ErrorObj::setSubroutine ( std::string const &  subroutine)
virtual

Definition at line 170 of file ErrorObj.cc.

References mf::ELextendedID::setSubroutine(), and xid_.

Referenced by eo_emit().

171  {
172  xid_.setSubroutine((subroutine[0] == ' ') ? subroutine.substr(1) :
173  subroutine);
174  }
void setSubroutine(std::string const &subroutine)
Definition: ELextendedID.cc:93
ELextendedID xid_
Definition: ErrorObj.h:81
void mf::ErrorObj::setTimestamp ( timeval const &  t)
virtual

Definition at line 241 of file ErrorObj.cc.

References timestamp_.

242  {
243  timestamp_ = t;
244  }
timeval timestamp_
Definition: ErrorObj.h:83
timeval mf::ErrorObj::timestamp ( ) const

Definition at line 73 of file ErrorObj.cc.

References timestamp_.

Referenced by mfplugins::ELsyslog::fillPrefix(), and mf::service::ELdestination::fillPrefix().

74  {
75  return timestamp_;
76  }
timeval timestamp_
Definition: ErrorObj.h:83

Member Data Documentation

std::string mf::ErrorObj::filename_ {}
private

Definition at line 89 of file ErrorObj.h.

Referenced by ErrorObj(), and filename().

std::string mf::ErrorObj::idOverflow_ {}
private

Definition at line 82 of file ErrorObj.h.

Referenced by clear(), ErrorObj(), idOverflow(), and setID().

std::list<std::string> mf::ErrorObj::items_ {}
private

Definition at line 84 of file ErrorObj.h.

Referenced by clear(), eo_emit(), ErrorObj(), fullText(), and items().

std::string mf::ErrorObj::iteration_ {}
private

Definition at line 86 of file ErrorObj.h.

Referenced by clear(), context(), ErrorObj(), iteration(), setContext(), and setIteration().

int mf::ErrorObj::lineNumber_ {}
private

Definition at line 90 of file ErrorObj.h.

Referenced by ErrorObj(), and lineNumber().

std::ostringstream mf::ErrorObj::oss_ {}
private

Definition at line 87 of file ErrorObj.h.

Referenced by clear(), ErrorObj(), operator<<(), and opltlt().

bool mf::ErrorObj::reactedTo_ {false}
private

Definition at line 85 of file ErrorObj.h.

Referenced by clear(), ErrorObj(), reactedTo(), and setReactedTo().

int mf::ErrorObj::serial_ {}
private

Definition at line 80 of file ErrorObj.h.

Referenced by clear(), ErrorObj(), serial(), and set().

timeval mf::ErrorObj::timestamp_ {0, 0}
private

Definition at line 83 of file ErrorObj.h.

Referenced by clear(), ErrorObj(), set(), setTimestamp(), and timestamp().

bool mf::ErrorObj::verbatim_ {false}
private

Definition at line 88 of file ErrorObj.h.

Referenced by clear(), ErrorObj(), and is_verbatim().

ELextendedID mf::ErrorObj::xid_ {}
private

The documentation for this class was generated from the following files: