CMS 3D CMS Logo

ELseverityLevel.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 //
3 // ELseverityLevel.cc - implement objects that encode a message's urgency
4 //
5 // Both frameworker and user will often pass one of the
6 // instantiated severity levels to logger methods.
7 //
8 // The only other methods of ELseverityLevel a frameworker
9 // might use is to check the relative level of two severities
10 // using operator<() or the like.
11 //
12 // 29-Jun-1998 mf Created file.
13 // 26-Aug-1998 WEB Made ELseverityLevel object less weighty.
14 // 16-Jun-1999 mf Added constructor from string, plus two lists
15 // of names to match. Also added default constructor,
16 // more streamlined than default lev on original.
17 // 23-Jun-1999 mf Modifications to properly handle pre-main order
18 // of initialization issues:
19 // Instantiation ofthe 14 const ELseverity &'s
20 // Instantiation of objectsInitialized as false
21 // Constructor of ELinitializeGlobalSeverityObjects
22 // Removed guarantor function in favor of the
23 // constructor.
24 // 30-Jun-1999 mf Modifications to eliminate propblems with order of
25 // globals initializations:
26 // Constructor from lev calls translate()
27 // Constructor from string uses translate()
28 // translate() method
29 // List of strings for names in side getname() etc.
30 // Immediate initilization of ELsevLevGlobals
31 // Mods involving ELinitializeGlobalSeverityObjects
32 // 12-Jun-2000 web Final fix to global static initialization problem
33 // 27-Jun-2000 web Fix order-of-static-destruction problem
34 // 24-Aug-2000 web Fix defective C++ switch generation
35 // 13-Jun-2007 mf Change (requested by CMS) the name Severe to System
36 // (since that his how MessageLogger uses that level)
37 // 21-Apr-2009 mf Change the symbol for ELsev_success (which is used
38 // by CMS for LogDebug) from -! to -d.
39 // ----------------------------------------------------------------------
40 
41 #include <ostream>
42 
45 
46 // Possible Traces
47 // #define ELsevConTRACE
48 
49 namespace edm {
50 
51  // ----------------------------------------------------------------------
52  // Helper to construct the string->ELsev_ map on demand:
53  // ----------------------------------------------------------------------
54 
55  typedef std::map<ELstring const, ELseverityLevel::ELsev_> ELmap;
56 
57  static ELmap const& loadMap() {
58  static const ELmap m = {{ELzeroSeverity.getSymbol(), ELseverityLevel::ELsev_zeroSeverity},
64  {ELdebug.getInputStr(), ELseverityLevel::ELsev_success},
66  {ELinfo.getSymbol(), ELseverityLevel::ELsev_info},
68  {ELinfo.getInputStr(), ELseverityLevel::ELsev_info},
69  {ELinfo.getVarName(), ELseverityLevel::ELsev_info},
76  {ELerror.getInputStr(), ELseverityLevel::ELsev_error},
77  {ELerror.getVarName(), ELseverityLevel::ELsev_error},
84  {ELsevere.getInputStr(), ELseverityLevel::ELsev_severe},
90 
91  return m;
92  }
93 
94  // ----------------------------------------------------------------------
95  // Birth/death:
96  // ----------------------------------------------------------------------
97 
98  ELseverityLevel::ELseverityLevel(enum ELsev_ lev) : myLevel(lev) {
99 #ifdef ELsevConTRACE
100  std::cerr << "--- ELseverityLevel " << lev << " (" << getName() << ")\n" << std::flush;
101 #endif
102  }
103 
105  static ELmap const& m = loadMap();
106 
107  ELmap::const_iterator i = m.find(s);
108  myLevel = (i == m.end()) ? ELsev_unspecified : i->second;
109  }
110 
112 
113  // ----------------------------------------------------------------------
114  // Comparator:
115  // ----------------------------------------------------------------------
116 
117  int ELseverityLevel::cmp(ELseverityLevel const& e) const { return myLevel - e.myLevel; }
118 
119  // ----------------------------------------------------------------------
120  // Accessors:
121  // ----------------------------------------------------------------------
122 
123  int ELseverityLevel::getLevel() const { return myLevel; }
124 
127 
128  switch (myLevel) {
129  default:
130  result = "0";
131  break;
132  case ELsev_zeroSeverity:
133  result = "--";
134  break;
135  case ELsev_success:
136  result = "-d";
137  break; // 4/21/09 mf
138  case ELsev_info:
139  result = "-i";
140  break;
141  case ELsev_warning:
142  result = "-w";
143  break;
144  case ELsev_error:
145  result = "-e";
146  break;
147  case ELsev_unspecified:
148  result = "??";
149  break;
150  case ELsev_severe:
151  result = "-s";
152  break;
154  result = "!!";
155  break;
156  }; // switch
157 
158  return result;
159  }
160 
163 
164  switch (myLevel) {
165  default:
166  result = "?no value?";
167  break;
168  case ELsev_zeroSeverity:
169  result = "--";
170  break;
171  case ELsev_success:
172  result = "Debug";
173  break; // 4/21/09 mf
174  case ELsev_info:
175  result = "Info";
176  break;
177  case ELsev_warning:
178  result = "Warning";
179  break;
180  case ELsev_error:
181  result = "Error";
182  break;
183  case ELsev_unspecified:
184  result = "??";
185  break;
186  case ELsev_severe:
187  result = "System";
188  break; // 6/13/07 mf
190  result = "!!";
191  break;
192  }; // switch
193 
194  return result;
195  }
196 
199 
200  switch (myLevel) {
201  default:
202  result = "?no value?";
203  break;
204  case ELsev_zeroSeverity:
205  result = "ZERO";
206  break;
207  case ELsev_success:
208  result = "DEBUG";
209  break;
210  case ELsev_info:
211  result = "INFO";
212  break;
213  case ELsev_warning:
214  result = "WARNING";
215  break;
216  case ELsev_error:
217  result = "ERROR";
218  break;
219  case ELsev_unspecified:
220  result = "UNSPECIFIED";
221  break;
222  case ELsev_severe:
223  result = "SYSTEM";
224  break; // 6/13/07 mf
226  result = "HIGHEST";
227  break;
228  }; // switch
229 
230  return result;
231  }
232 
235 
236  switch (myLevel) {
237  default:
238  result = "?no value? ";
239  break;
240  case ELsev_zeroSeverity:
241  result = "ELzeroSeverity ";
242  break;
243  case ELsev_success:
244  result = "ELdebug ";
245  break; // 4/21/09
246  case ELsev_info:
247  result = "ELinfo ";
248  break;
249  case ELsev_warning:
250  result = "ELwarning ";
251  break;
252  case ELsev_error:
253  result = "ELerror ";
254  break;
255  case ELsev_unspecified:
256  result = "ELunspecified ";
257  break;
258  case ELsev_severe:
259  result = "ELsystem ";
260  break; // 6/13/07
262  result = "ELhighestSeverity";
263  break;
264  }; // switch
265 
266  return result;
267  }
268 
269  // ----------------------------------------------------------------------
270  // Emitter:
271  // ----------------------------------------------------------------------
272 
273  std::ostream& operator<<(std::ostream& os, const ELseverityLevel& sev) { return os << " -" << sev.getName() << "- "; }
274 
275  // ----------------------------------------------------------------------
276  // Declare the globally available severity objects,
277  // one generator function and one proxy per non-default ELsev_:
278  // ----------------------------------------------------------------------
279 
282  return e;
283  }
285 
288  return e;
289  }
291 
294  return e;
295  }
297 
300  return e;
301  }
303 
306  return e;
307  }
309 
312  return e;
313  }
315 
318  return e;
319  }
321 
324  return e;
325  }
327 
328  // ----------------------------------------------------------------------
329 
330 } // end of namespace edm */
edm::ELzeroSeverityGen
ELslGen ELzeroSeverityGen
edm::ELseverityLevel::ELsev_highestSeverity
Definition: ELseverityLevel.h:118
edm::ELseverityLevel::ELsev_zeroSeverity
Definition: ELseverityLevel.h:104
edm::ELseverityLevel::getLevel
int getLevel() const
Definition: ELseverityLevel.cc:123
mps_fire.i
i
Definition: mps_fire.py:355
edm::ELwarning
const ELslProxy< ELwarningGen > ELwarning
Definition: ELseverityLevel.cc:302
edm::ELseverityLevel::getVarName
const ELstring getVarName() const
Definition: ELseverityLevel.cc:233
edm::ELseverityLevel::ELsev_
ELsev_
Definition: ELseverityLevel.h:101
edm::ELzeroSeverity
const ELslProxy< ELzeroSeverityGen > ELzeroSeverity
Definition: ELseverityLevel.cc:284
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ELerrorGen
ELslGen ELerrorGen
edm::ELinfoGen
ELslGen ELinfoGen
edm::ELseverityLevel::~ELseverityLevel
~ELseverityLevel()
Definition: ELseverityLevel.cc:111
edm::ELseverityLevel::getSymbol
const ELstring getSymbol() const
Definition: ELseverityLevel.cc:125
edm::ELwarningGen
ELslGen ELwarningGen
edm::ELseverityLevel::ELsev_severe
Definition: ELseverityLevel.h:116
edm::ELslProxy
Definition: ELseverityLevel.h:64
edm::operator<<
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
Definition: HLTGlobalStatus.h:106
edm::ELseverityLevel::getInputStr
const ELstring getInputStr() const
Definition: ELseverityLevel.cc:197
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::ELstring
std::string ELstring
Definition: ELstring.h:21
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
edm::ELsevereGen
ELslGen ELsevereGen
edm::ELseverityLevel::ELsev_error
Definition: ELseverityLevel.h:112
edm::ELseverityLevel::ELsev_unspecified
Definition: ELseverityLevel.h:114
ELmap.h
edm::ELsevere
const ELslProxy< ELsevereGen > ELsevere
Definition: ELseverityLevel.cc:320
edm::ELdebug
const ELslProxy< ELdebugGen > ELdebug
Definition: ELseverityLevel.cc:290
edm::ELseverityLevel::ELsev_warning
Definition: ELseverityLevel.h:110
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::ELmap
std::map< ELstring const, ELseverityLevel::ELsev_ > ELmap
Definition: ELseverityLevel.cc:55
edm::ELseverityLevel::ELsev_success
Definition: ELseverityLevel.h:106
ELseverityLevel.h
edm::ELseverityLevel
Definition: ELseverityLevel.h:96
edm::ELseverityLevel::getName
const ELstring getName() const
Definition: ELseverityLevel.cc:161
edm::ELerror
const ELslProxy< ELerrorGen > ELerror
Definition: ELseverityLevel.cc:308
edm::ELhighestSeverityGen
ELslGen ELhighestSeverityGen
edm::ELseverityLevel::myLevel
int myLevel
Definition: ELseverityLevel.h:151
edm::ELunspecifiedGen
ELslGen ELunspecifiedGen
edm::ELseverityLevel::cmp
int cmp(ELseverityLevel const &e) const
Definition: ELseverityLevel.cc:117
edm::ELinfo
const ELslProxy< ELinfoGen > ELinfo
Definition: ELseverityLevel.cc:296
mps_fire.result
result
Definition: mps_fire.py:303
edm::ELseverityLevel::ELseverityLevel
ELseverityLevel(ELsev_ lev=ELsev_unspecified)
Definition: ELseverityLevel.cc:98
edm::ELunspecified
const ELslProxy< ELunspecifiedGen > ELunspecified
Definition: ELseverityLevel.cc:314
edm::loadMap
static ELmap const & loadMap()
Definition: ELseverityLevel.cc:57
edm::ELdebugGen
ELslGen ELdebugGen
edm::ELseverityLevel::ELsev_info
Definition: ELseverityLevel.h:108
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37