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 
73  m[ ELdebug.getSymbol() ] = ELseverityLevel::ELsev_success
74  , m[ ELdebug.getName() ] = ELseverityLevel::ELsev_success
75  , m[ ELdebug.getInputStr() ] = ELseverityLevel::ELsev_success
76  , m[ ELdebug.getVarName() ] = ELseverityLevel::ELsev_success
77  ;
78 
79  m[ ELinfo.getSymbol() ] = ELseverityLevel::ELsev_info
80  , m[ ELinfo.getName() ] = ELseverityLevel::ELsev_info
81  , m[ ELinfo.getInputStr() ] = ELseverityLevel::ELsev_info
82  , m[ ELinfo.getVarName() ] = ELseverityLevel::ELsev_info
83  ;
84 
85  m[ ELwarning.getSymbol() ] = ELseverityLevel::ELsev_warning
86  , m[ ELwarning.getName() ] = ELseverityLevel::ELsev_warning
87  , m[ ELwarning.getInputStr() ] = ELseverityLevel::ELsev_warning
88  , m[ ELwarning.getVarName() ] = ELseverityLevel::ELsev_warning
89  ;
90 
91  m[ ELerror.getSymbol() ] = ELseverityLevel::ELsev_error
92  , m[ ELerror.getName() ] = ELseverityLevel::ELsev_error
93  , m[ ELerror.getInputStr() ] = ELseverityLevel::ELsev_error
94  , m[ ELerror.getVarName() ] = ELseverityLevel::ELsev_error
95  ;
96 
101  ;
102 
103  m[ ELsevere.getSymbol() ] = ELseverityLevel::ELsev_severe
104  , m[ ELsevere.getName() ] = ELseverityLevel::ELsev_severe
105  , m[ ELsevere.getInputStr() ] = ELseverityLevel::ELsev_severe
106  , m[ ELsevere.getVarName() ] = ELseverityLevel::ELsev_severe
107  ;
108 
113  ;
114 
115  return m;
116 
117  }
118 
119 // ----------------------------------------------------------------------
120 // Birth/death:
121 // ----------------------------------------------------------------------
122 
123 ELseverityLevel::ELseverityLevel( enum ELsev_ lev ) : myLevel( lev ) {
124 
125  #ifdef ELsevConTRACE
126  std::cerr << "--- ELseverityLevel " << lev
127  << " (" << getName() << ")\n"
128  << std::flush;
129  #endif
130 
131 }
132 
133 
135 
136  static ELmap const & m = loadMap();
137 
138  ELmap::const_iterator i = m.find( s );
139  myLevel = ( i == m.end() ) ? ELsev_unspecified : i->second;
140 
141 }
142 
144 
145 
146 // ----------------------------------------------------------------------
147 // Comparator:
148 // ----------------------------------------------------------------------
149 
150 int ELseverityLevel::cmp( ELseverityLevel const & e ) const {
151  return myLevel - e.myLevel;
152 }
153 
154 
155 // ----------------------------------------------------------------------
156 // Accessors:
157 // ----------------------------------------------------------------------
158 
160  return myLevel;
161 }
162 
163 
166 
167  switch ( myLevel ) {
168  default : result = "0" ; break;
169  case ELsev_zeroSeverity : result = "--"; break;
170  case ELsev_success : result = "-d"; break; // 4/21/09 mf
171  case ELsev_info : result = "-i"; break;
172  case ELsev_warning : result = "-w"; break;
173  case ELsev_error : result = "-e"; break;
174  case ELsev_unspecified : result = "??"; break;
175  case ELsev_severe : result = "-s"; break;
176  case ELsev_highestSeverity: result = "!!"; break;
177  }; // switch
178 
179  return result;
180 }
181 
182 
185 
186  switch ( myLevel ) {
187  default : result = "?no value?"; break;
188  case ELsev_zeroSeverity : result = "--" ; break;
189  case ELsev_success : result = "Debug" ; break; // 4/21/09 mf
190  case ELsev_info : result = "Info" ; break;
191  case ELsev_warning : result = "Warning" ; break;
192  case ELsev_error : result = "Error" ; break;
193  case ELsev_unspecified : result = "??" ; break;
194  case ELsev_severe : result = "System" ; break; // 6/13/07 mf
195  case ELsev_highestSeverity: result = "!!" ; break;
196  }; // switch
197 
198  return result;
199 }
200 
201 
204 
205  switch ( myLevel ) {
206  default : result = "?no value?" ; break;
207  case ELsev_zeroSeverity : result = "ZERO" ; break;
208  case ELsev_success : result = "DEBUG" ; break;
209  case ELsev_info : result = "INFO" ; break;
210  case ELsev_warning : result = "WARNING" ; break;
211  case ELsev_error : result = "ERROR" ; break;
212  case ELsev_unspecified : result = "UNSPECIFIED"; break;
213  case ELsev_severe : result = "SYSTEM" ; break; // 6/13/07 mf
214  case ELsev_highestSeverity: result = "HIGHEST" ; break;
215  }; // switch
216 
217  return result;
218 }
219 
220 
223 
224  switch ( myLevel ) {
225  default : result = "?no value? "; break;
226  case ELsev_zeroSeverity : result = "ELzeroSeverity "; break;
227  case ELsev_success : result = "ELdebug "; break;// 4/21/09
228  case ELsev_info : result = "ELinfo "; break;
229  case ELsev_warning : result = "ELwarning "; break;
230  case ELsev_error : result = "ELerror "; break;
231  case ELsev_unspecified : result = "ELunspecified "; break;
232  case ELsev_severe : result = "ELsystem "; break;// 6/13/07
233  case ELsev_highestSeverity: result = "ELhighestSeverity"; break;
234  }; // switch
235 
236  return result;
237 }
238 
239 
240 // ----------------------------------------------------------------------
241 // Emitter:
242 // ----------------------------------------------------------------------
243 
244 std::ostream & operator<<( std::ostream & os, const ELseverityLevel & sev ) {
245  return os << " -" << sev.getName() << "- ";
246 }
247 
248 
249 // ----------------------------------------------------------------------
250 // Declare the globally available severity objects,
251 // one generator function and one proxy per non-default ELsev_:
252 // ----------------------------------------------------------------------
253 
256  return e;
257 }
259 
262  return e;
263 }
265 
268  return e;
269 }
271 
274  return e;
275 }
277 
280  return e;
281 }
283 
286  return e;
287 }
289 
292  return e;
293 }
295 
298  return e;
299 }
301 
302 // ----------------------------------------------------------------------
303 
304 
305 } // end of namespace edm */
ELslGen ELinfoGen
ELslProxy< ELdebugGen > const ELdebug
ELslGen ELzeroSeverityGen
int i
Definition: DBlmapReader.cc:9
int cmp(ELseverityLevel const &e) const
ELslGen ELerrorGen
ELslProxy< ELunspecifiedGen > const ELunspecified
ELseverityLevel(ELsev_ lev=ELsev_unspecified)
const ELstring getVarName() const
ELslProxy< ELwarningGen > const ELwarning
ELslProxy< ELhighestSeverityGen > const ELhighestSeverity
ELslGen ELdebugGen
static ELmap const & loadMap()
const ELstring getSymbol() const
ELslProxy< ELzeroSeverityGen > const ELzeroSeverity
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 ELhighestSeverityGen
ELslProxy< ELinfoGen > const ELinfo
ELslProxy< ELsevereGen > const ELsevere
ELslGen ELunspecifiedGen
ELslGen ELsevereGen
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
std::string ELstring
Definition: ELstring.h:26