CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
47 // Possible Traces
48 // #define ELsevConTRACE
49 
50 
51 namespace edm
52 {
53 
54 
55 // ----------------------------------------------------------------------
56 // Helper to construct the string->ELsev_ map on demand:
57 // ----------------------------------------------------------------------
58 
59 typedef std::map< ELstring const, ELseverityLevel::ELsev_ > ELmap;
60 
61 static
62 ELmap const & loadMap() {
63 
64  static ELmap m;
65 
66 
71  ;
72 
75  , m[ ELincidental.getInputStr() ] = ELseverityLevel::ELsev_incidental
77  ;
78 
79  m[ ELsuccess.getSymbol() ] = ELseverityLevel::ELsev_success
80  , m[ ELsuccess.getName() ] = ELseverityLevel::ELsev_success
81  , m[ ELsuccess.getInputStr() ] = ELseverityLevel::ELsev_success
82  , m[ ELsuccess.getVarName() ] = ELseverityLevel::ELsev_success
83  ;
84 
85  m[ ELinfo.getSymbol() ] = ELseverityLevel::ELsev_info
86  , m[ ELinfo.getName() ] = ELseverityLevel::ELsev_info
87  , m[ ELinfo.getInputStr() ] = ELseverityLevel::ELsev_info
88  , m[ ELinfo.getVarName() ] = ELseverityLevel::ELsev_info
89  ;
90 
91  m[ ELwarning.getSymbol() ] = ELseverityLevel::ELsev_warning
92  , m[ ELwarning.getName() ] = ELseverityLevel::ELsev_warning
93  , m[ ELwarning.getInputStr() ] = ELseverityLevel::ELsev_warning
94  , m[ ELwarning.getVarName() ] = ELseverityLevel::ELsev_warning
95  ;
96 
99  , m[ ELwarning2.getInputStr() ] = ELseverityLevel::ELsev_warning2
100  , m[ ELwarning2.getVarName() ] = ELseverityLevel::ELsev_warning2
101  ;
102 
103  m[ ELerror.getSymbol() ] = ELseverityLevel::ELsev_error
104  , m[ ELerror.getName() ] = ELseverityLevel::ELsev_error
105  , m[ ELerror.getInputStr() ] = ELseverityLevel::ELsev_error
106  , m[ ELerror.getVarName() ] = ELseverityLevel::ELsev_error
107  ;
108 
109  m[ ELerror2.getSymbol() ] = ELseverityLevel::ELsev_error2
110  , m[ ELerror2.getName() ] = ELseverityLevel::ELsev_error2
111  , m[ ELerror2.getInputStr() ] = ELseverityLevel::ELsev_error2
112  , m[ ELerror2.getVarName() ] = ELseverityLevel::ELsev_error2
113  ;
114 
115  m[ ELnextEvent.getSymbol() ] = ELseverityLevel::ELsev_next
116  , m[ ELnextEvent.getName() ] = ELseverityLevel::ELsev_next
117  , m[ ELnextEvent.getInputStr() ] = ELseverityLevel::ELsev_next
118  , m[ ELnextEvent.getVarName() ] = ELseverityLevel::ELsev_next
119  ;
120 
125  ;
126 
127  m[ ELsevere.getSymbol() ] = ELseverityLevel::ELsev_severe
128  , m[ ELsevere.getName() ] = ELseverityLevel::ELsev_severe
129  , m[ ELsevere.getInputStr() ] = ELseverityLevel::ELsev_severe
130  , m[ ELsevere.getVarName() ] = ELseverityLevel::ELsev_severe
131  ;
132 
133  m[ ELsevere2.getSymbol() ] = ELseverityLevel::ELsev_severe2
134  , m[ ELsevere2.getName() ] = ELseverityLevel::ELsev_severe2
135  , m[ ELsevere2.getInputStr() ] = ELseverityLevel::ELsev_severe2
136  , m[ ELsevere2.getVarName() ] = ELseverityLevel::ELsev_severe2
137  ;
138 
139  m[ ELabort.getSymbol() ] = ELseverityLevel::ELsev_abort
140  , m[ ELabort.getName() ] = ELseverityLevel::ELsev_abort
141  , m[ ELabort.getInputStr() ] = ELseverityLevel::ELsev_abort
142  , m[ ELabort.getVarName() ] = ELseverityLevel::ELsev_abort
143  ;
144 
145  m[ ELfatal.getSymbol() ] = ELseverityLevel::ELsev_fatal
146  , m[ ELfatal.getName() ] = ELseverityLevel::ELsev_fatal
147  , m[ ELfatal.getInputStr() ] = ELseverityLevel::ELsev_fatal
148  , m[ ELfatal.getVarName() ] = ELseverityLevel::ELsev_fatal
149  ;
150 
155  ;
156 
157  return m;
158 
159 }
160 
161 
162 // ----------------------------------------------------------------------
163 // Birth/death:
164 // ----------------------------------------------------------------------
165 
166 ELseverityLevel::ELseverityLevel( enum ELsev_ lev ) : myLevel( lev ) {
167 
168  #ifdef ELsevConTRACE
169  std::cerr << "--- ELseverityLevel " << lev
170  << " (" << getName() << ")\n"
171  << std::flush;
172  #endif
173 
174 }
175 
176 
178 
179  static ELmap const & m = loadMap();
180 
181  ELmap::const_iterator i = m.find( s );
182  myLevel = ( i == m.end() ) ? ELsev_unspecified : i->second;
183 
184 }
185 
186 
188 
189 
190 // ----------------------------------------------------------------------
191 // Comparator:
192 // ----------------------------------------------------------------------
193 
194 int ELseverityLevel::cmp( ELseverityLevel const & e ) const {
195  return myLevel - e.myLevel;
196 }
197 
198 
199 // ----------------------------------------------------------------------
200 // Accessors:
201 // ----------------------------------------------------------------------
202 
204  return myLevel;
205 }
206 
207 
210 
211  switch ( myLevel ) {
212  default : result = "0" ; break;
213  case ELsev_zeroSeverity : result = "--"; break;
214  case ELsev_incidental : result = ".."; break;
215  case ELsev_success : result = "-d"; break; // 4/21/09 mf
216  case ELsev_info : result = "-i"; break;
217  case ELsev_warning : result = "-w"; break;
218  case ELsev_warning2 : result = "-W"; break;
219  case ELsev_error : result = "-e"; break;
220  case ELsev_error2 : result = "-E"; break;
221  case ELsev_next : result = "-n"; break;
222  case ELsev_unspecified : result = "??"; break;
223  case ELsev_severe : result = "-s"; break;
224  case ELsev_severe2 : result = "-S"; break;
225  case ELsev_abort : result = "-A"; break;
226  case ELsev_fatal : result = "-F"; break;
227  case ELsev_highestSeverity: result = "!!"; break;
228  }; // switch
229 
230  return result;
231 }
232 
233 
236 
237  switch ( myLevel ) {
238  default : result = "?no value?"; break;
239  case ELsev_zeroSeverity : result = "--" ; break;
240  case ELsev_incidental : result = ".." ; break;
241  case ELsev_success : result = "Debug" ; break; // 4/21/09 mf
242  case ELsev_info : result = "Info" ; break;
243  case ELsev_warning : result = "Warning" ; break;
244  case ELsev_warning2 : result = "Warning!" ; break;
245  case ELsev_error : result = "Error" ; break;
246  case ELsev_error2 : result = "Error!" ; break;
247  case ELsev_next : result = "Next" ; break;
248  case ELsev_unspecified : result = "??" ; break;
249  case ELsev_severe : result = "System" ; break; // 6/13/07 mf
250  case ELsev_severe2 : result = "Severe!" ; break;
251  case ELsev_abort : result = "Abort!" ; break;
252  case ELsev_fatal : result = "Fatal!" ; break;
253  case ELsev_highestSeverity: result = "!!" ; break;
254  }; // switch
255 
256  return result;
257 }
258 
259 
262 
263  switch ( myLevel ) {
264  default : result = "?no value?" ; break;
265  case ELsev_zeroSeverity : result = "ZERO" ; break;
266  case ELsev_incidental : result = "INCIDENTAL" ; break;
267  case ELsev_success : result = "DEBUG" ; break;
268  case ELsev_info : result = "INFO" ; break;
269  case ELsev_warning : result = "WARNING" ; break;
270  case ELsev_warning2 : result = "WARNING2" ; break;
271  case ELsev_error : result = "ERROR" ; break;
272  case ELsev_error2 : result = "ERROR2" ; break;
273  case ELsev_next : result = "NEXT" ; break;
274  case ELsev_unspecified : result = "UNSPECIFIED"; break;
275  case ELsev_severe : result = "SYSTEM" ; break; // 6/13/07 mf
276  case ELsev_severe2 : result = "SEVERE2" ; break;
277  case ELsev_abort : result = "ABORT" ; break;
278  case ELsev_fatal : result = "FATAL" ; break;
279  case ELsev_highestSeverity: result = "HIGHEST" ; break;
280  }; // switch
281 
282  return result;
283 }
284 
285 
288 
289  switch ( myLevel ) {
290  default : result = "?no value? "; break;
291  case ELsev_zeroSeverity : result = "ELzeroSeverity "; break;
292  case ELsev_incidental : result = "ELincidental "; break;
293  case ELsev_success : result = "ELdebug "; break;// 4/21/09
294  case ELsev_info : result = "ELinfo "; break;
295  case ELsev_warning : result = "ELwarning "; break;
296  case ELsev_warning2 : result = "ELwarning2 "; break;
297  case ELsev_error : result = "ELerror "; break;
298  case ELsev_error2 : result = "ELerror2 "; break;
299  case ELsev_next : result = "ELnextEvent "; break;
300  case ELsev_unspecified : result = "ELunspecified "; break;
301  case ELsev_severe : result = "ELsystem "; break;// 6/13/07
302  case ELsev_severe2 : result = "ELsevere2 "; break;
303  case ELsev_abort : result = "ELabort "; break;
304  case ELsev_fatal : result = "ELfatal "; break;
305  case ELsev_highestSeverity: result = "ELhighestSeverity"; break;
306  }; // switch
307 
308  return result;
309 }
310 
311 
312 // ----------------------------------------------------------------------
313 // Emitter:
314 // ----------------------------------------------------------------------
315 
316 std::ostream & operator<<( std::ostream & os, const ELseverityLevel & sev ) {
317  return os << " -" << sev.getName() << "- ";
318 }
319 
320 
321 // ----------------------------------------------------------------------
322 // Declare the globally available severity objects,
323 // one generator function and one proxy per non-default ELsev_:
324 // ----------------------------------------------------------------------
325 
328  return e;
329 }
331 
334  return e;
335 }
337 
340  return e;
341 }
343 
346  return e;
347 }
349 
352  return e;
353 }
355 
358  return e;
359 }
361 
364  return e;
365 }
367 
370  return e;
371 }
373 
376  return e;
377 }
379 
382  return e;
383 }
385 
388  return e;
389 }
391 
394  return e;
395 }
397 
400  return e;
401 }
403 
406  return e;
407 }
409 
412  return e;
413 }
415 
416 // ----------------------------------------------------------------------
417 
418 
419 } // end of namespace edm */
ELslGen ELinfoGen
ELslGen ELzeroSeverityGen
int i
Definition: DBlmapReader.cc:9
ELslProxy< ELnextEventGen > const ELnextEvent
int cmp(ELseverityLevel const &e) const
ELslProxy< ELsuccessGen > const ELsuccess
ELslGen ELerrorGen
ELslGen ELincidentalGen
ELslGen ELerror2Gen
ELslProxy< ELfatalGen > const ELfatal
ELslProxy< ELunspecifiedGen > const ELunspecified
ELseverityLevel(ELsev_ lev=ELsev_unspecified)
const ELstring getVarName() const
ELslProxy< ELwarningGen > const ELwarning
ELslProxy< ELhighestSeverityGen > const ELhighestSeverity
static ELmap const & loadMap()
ELslProxy< ELsevere2Gen > const ELsevere2
const ELstring getSymbol() const
ELslGen ELnextEventGen
ELslProxy< ELzeroSeverityGen > const ELzeroSeverity
ELslProxy< ELincidentalGen > const ELincidental
ELslProxy< ELabortGen > const ELabort
ELslProxy< ELerrorGen > const ELerror
ELslGen ELwarningGen
tuple result
Definition: query.py:137
const ELstring getName() const
const ELstring getInputStr() const
std::map< ELstring const, ELseverityLevel::ELsev_ > ELmap
ELslGen ELabortGen
ELslGen ELhighestSeverityGen
ELslProxy< ELinfoGen > const ELinfo
ELslGen ELsevere2Gen
ELslProxy< ELerror2Gen > const ELerror2
ELslGen ELwarning2Gen
ELslProxy< ELsevereGen > const ELsevere
ELslGen ELsuccessGen
ELslProxy< ELwarning2Gen > const ELwarning2
ELslGen ELunspecifiedGen
ELslGen ELsevereGen
ELslGen ELfatalGen
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
std::string ELstring
Definition: ELstring.h:26