CMS 3D CMS Logo

ELadministrator.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 //
3 // ELadministrator.cc
4 //
5 // Methods of ELadministrator.
6 //
7 // History:
8 //
9 // 7/2/98 mf Created
10 // 7/6/98 mf Added ELadministratorX knowledge
11 // 6/16/99 jvr Attaches a destination when an error is logged and
12 // no destinations are attached $$ JV:1
13 // 6/18/99 jvr/mf Constructor for ELadministratorX uses explcitly
14 // constructed ELseverityLevels in its init list, rather
15 // than objectslike ELabort, which may not yet have
16 // been fully constructed. Repairs a problem with ELcout.
17 // 6/23/99 mf Made emptyContextSUpplier static to this comp unit.
18 // 12/20/99 mf Added virtual destructor to ELemptyContextSupplier.
19 // 2/29/00 mf swapContextSupplier.
20 // 4/05/00 mf swapProcess.
21 // 5/03/00 mf When aborting, changed exit() to abort() so that dump
22 // will reflect true condition without unwinding things.
23 // 6/6/00 web Consolidated ELadministrator/X.
24 // 6/7/00 web Reflect consolidation of ELdestination/X.
25 // 6/12/00 web Attach cerr, rather than cout, in case of no previously-
26 // attached destination; using -> USING.
27 // 3/6/00 mf Attach taking name to id the destination, getELdestControl()
28 // 3/14/01 mf exitThreshold
29 // 1/10/06 mf finish()
30 //
31 // ---- CMS version
32 //
33 // 12/12/05 mf change exit() to throw edm::exception
34 //
35 //-----------------------------------------------------------------------
36 
37 // Directory of methods:
38 //----------------------
39 
40 // ELadministrator::setProcess( const ELstring & process )
41 // ELadministrator::swapProcess( const ELstring & process )
42 // ELadministrator::attach( const ELdestination & sink )
43 // ELadministrator::attach( const ELdestination & sink, const ELstring & name )
44 // ELadministrator::checkSeverity()
45 // ELadministrator::severityCount( const ELseverityLevel & sev ) const
46 // ELadministrator::severityCount( const ELseverityLevel & from,
47 // const ELseverityLevel & to ) const
48 // ELadministrator::resetSeverityCount( const ELseverityLevel & sev )
49 // ELadministrator::resetSeverityCount( const ELseverityLevel & from,
50 // const ELseverityLevel & to )
51 // ELadministrator::resetSeverityCount()
52 // ELadministrator::setThresholds( const ELseverityLevel & sev )
53 // ELadministrator::setLimits( const ELstring & id, int limit )
54 // ELadministrator::setLimits( const ELseverityLevel & sev, int limit )
55 // ELadministrator::setIntervals( const ELstring & id, int interval )
56 // ELadministrator::setIntervals( const ELseverityLevel & sev, int interval )
57 // ELadministrator::setTimespans( const ELstring & id, int seconds )
58 // ELadministrator::setTimespans( const ELseverityLevel & sev, int seconds )
59 // ELadministrator::wipe()
60 // ELadministrator::finish()
61 //
62 // ELadministrator::process() const
63 // ELadministrator::context() const
64 // ELadministrator::abortThreshold() const
65 // ELadministrator::exitThreshold() const
66 // ELadministrator::sinks_
67 // ELadministrator::highSeverity() const
68 // ELadministrator::severityCounts( const int lev ) const
69 // ELadministrator::finishMsg()
70 // ELadministrator::clearMsg()
71 //
72 //
73 // ----------------------------------------------------------------------
74 
78 
80 
81 #include <iostream>
82 #include <sstream>
83 #include <list>
84 using std::cerr;
85 
86 namespace edm {
87  namespace service {
88 
89  // Possible Traces:
90  // #define ELadministratorCONSTRUCTOR_TRACE
91  // #define ELadTRACE_FINISH
92 
94  // severity level statistics keeping: // $$ mf 6/7/01
95  int lev = msg.xid().severity.getLevel();
96  ++severityCounts_[lev];
97  if (lev > highSeverity_.getLevel())
98  highSeverity_ = msg.xid().severity;
99 
100  // ----- send the message to each destination:
101  //
102  if (sinks_.begin() == sinks_.end()) {
103  std::cerr << "\nERROR LOGGED WITHOUT DESTINATION!\n";
104  std::cerr << "Attaching destination \"cerr\" to ELadministrator by default\n" << std::endl;
105  attach(std::make_shared<ELoutput>(std::cerr));
106  }
107  for (auto& sink : sinks_)
108  if (sink->log(msg))
109  msg.setReactedTo(true);
110 
111  return;
112  }
113 
114  // ----------------------------------------------------------------------
115  // ELadministrator functionality:
116  // ----------------------------------------------------------------------
117 
118  std::shared_ptr<ELdestination> ELadministrator::attach(std::shared_ptr<ELdestination> sink) {
119  sinks_.push_back(sink);
120  return sink;
121 
122  } // attach()
123 
125  const ELseverityLevel retval(highSeverity_);
127  return retval;
128 
129  } // checkSeverity()
130 
132  return severityCounts_[sev.getLevel()];
133 
134  } // severityCount()
135 
137  int k = from.getLevel();
138  int sum = severityCounts_[k];
139 
140  while (++k != to.getLevel())
141  sum += severityCounts_[k];
142 
143  return sum;
144 
145  } // severityCount()
146 
148  severityCounts_[sev.getLevel()] = 0;
149 
150  } // resetSeverityCount()
151 
153  for (int k = from.getLevel(); k <= to.getLevel(); ++k)
154  severityCounts_[k] = 0;
155 
156  } // resetSeverityCount()
157 
160 
161  } // resetSeverityCount()
162 
163  // ----------------------------------------------------------------------
164  // Accessors:
165  // ----------------------------------------------------------------------
166 
168 
169  int ELadministrator::severityCounts(const int lev) const { return severityCounts_[lev]; }
170 
171  // ----------------------------------------------------------------------
172  // Message handling:
173  // ----------------------------------------------------------------------
174 
175  // ----------------------------------------------------------------------
176  // The following do the indicated action to all attached destinations:
177  // ----------------------------------------------------------------------
178 
180  for (auto& sink : sinks_)
181  sink->threshold = sev;
182 
183  } // setThresholds()
184 
186  for (auto& sink : sinks_)
187  sink->limits.setLimit(id, limit);
188 
189  } // setLimits()
190 
192  for (auto& sink : sinks_)
193  sink->limits.setInterval(sev, interval);
194 
195  } // setIntervals()
196 
198  for (auto& sink : sinks_)
199  sink->limits.setInterval(id, interval);
200 
201  } // setIntervals()
202 
204  for (auto& sink : sinks_)
205  sink->limits.setLimit(sev, limit);
206 
207  } // setLimits()
208 
210  for (auto& sink : sinks_)
211  sink->limits.setTimespan(id, seconds);
212 
213  } // setTimespans()
214 
216  for (auto& sink : sinks_)
217  sink->limits.setTimespan(sev, seconds);
218 
219  } // setTimespans()
220 
222  for (auto& sink : sinks_)
223  sink->limits.wipe();
224 
225  } // wipe()
226 
228  for (auto& sink : sinks_)
229  sink->finish();
230 
231  } // wipe()
232 
233  ELadministrator::ELadministrator() : sinks_(), highSeverity_(ELseverityLevel(ELseverityLevel::ELsev_zeroSeverity)) {
234 #ifdef ELadministratorCONSTRUCTOR_TRACE
235  std::cerr << "ELadminstrator constructor\n";
236 #endif
237 
238  for (int lev = 0; lev < ELseverityLevel::nLevels; ++lev)
239  severityCounts_[lev] = 0;
240  }
241  //-*****************************
242  // The ELadminstrator destructor
243  //-*****************************
244 
246 #ifdef ELadministratorCONSTRUCTOR_TRACE
247  std::cerr << "ELadministrator Destructor\n";
248 #endif
249 
250  sinks_.clear();
251 
252  } // ~ELadministrator()
253 
254  // ----------------------------------------------------------------------
255 
256  } // end of namespace service
257 } // end of namespace edm
edm::service::ELadministrator::setIntervals
void setIntervals(const ELstring &id, int interval)
Definition: ELadministrator.cc:197
edm::service::ELadministrator::resetSeverityCount
void resetSeverityCount()
Definition: ELadministrator.cc:158
service
Definition: service.py:1
edm::ELseverityLevel::getLevel
int getLevel() const
Definition: ELseverityLevel.cc:123
edm::ELzeroSeverity
const ELslProxy< ELzeroSeverityGen > ELzeroSeverity
Definition: ELseverityLevel.cc:284
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ErrorObj
Definition: ErrorObj.h:44
edm::service::ELadministrator::severityCounts
int severityCounts(int lev) const
Definition: ELadministrator.cc:169
to
edm::service::ELadministrator::ELadministrator
ELadministrator()
Definition: ELadministrator.cc:233
mps_check.msg
tuple msg
Definition: mps_check.py:285
edm::service::ELadministrator::setThresholds
void setThresholds(const ELseverityLevel &sev)
Definition: ELadministrator.cc:179
edm::service::ELadministrator::highSeverity_
ELseverityLevel highSeverity_
Definition: ELadministrator.h:131
edm::service::ELadministrator::severityCount
int severityCount(const ELseverityLevel &sev) const
Definition: ELadministrator.cc:131
EDMException.h
edm::ELstring
std::string ELstring
Definition: ELstring.h:21
seconds
double seconds()
edm::service::ELadministrator::wipe
void wipe()
Definition: ELadministrator.cc:221
dqmdumpme.k
k
Definition: dqmdumpme.py:60
edm::service::ELadministrator::setLimits
void setLimits(const ELstring &id, int limit)
Definition: ELadministrator.cc:185
ELoutput.h
ELdestination.h
edm::service::ELadministrator::~ELadministrator
~ELadministrator()
Definition: ELadministrator.cc:245
edm::ELhighestSeverity
const ELslProxy< ELhighestSeverityGen > ELhighestSeverity
Definition: ELseverityLevel.cc:326
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
edm::ELseverityLevel::nLevels
Definition: ELseverityLevel.h:121
ELadministrator.h
edm::service::ELadministrator::checkSeverity
ELseverityLevel checkSeverity()
Definition: ELadministrator.cc:124
readEcalDQMStatus.interval
interval
Definition: readEcalDQMStatus.py:18
edm::service::ELadministrator::setTimespans
void setTimespans(const ELstring &id, int seconds)
Definition: ELadministrator.cc:209
edm::ELseverityLevel
Definition: ELseverityLevel.h:96
remoteMonitoring_LED_IterMethod_cfg.limit
limit
Definition: remoteMonitoring_LED_IterMethod_cfg.py:427
edm::service::ELadministrator::sinks_
std::list< edm::propagate_const< std::shared_ptr< ELdestination > > > sinks_
Definition: ELadministrator.h:130
edm::service::ELadministrator::finish
void finish()
Definition: ELadministrator.cc:227
edm::service::ELadministrator::log
void log(edm::ErrorObj &msg)
Definition: ELadministrator.cc:93
edm::service::ELadministrator::highSeverity
const ELseverityLevel & highSeverity() const
Definition: ELadministrator.cc:167
edm::service::ELadministrator::severityCounts_
int severityCounts_[ELseverityLevel::nLevels]
Definition: ELadministrator.h:132
edm::service::ELadministrator::attach
std::shared_ptr< ELdestination > attach(std::shared_ptr< ELdestination > sink)
Definition: ELadministrator.cc:118