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 const ELmap m = {
69  ,
70  { ELdebug.getSymbol() , ELseverityLevel::ELsev_success }
71  , { ELdebug.getName() , ELseverityLevel::ELsev_success }
72  , { ELdebug.getInputStr() , ELseverityLevel::ELsev_success }
73  , { ELdebug.getVarName() , ELseverityLevel::ELsev_success }
74  ,
75  { ELinfo.getSymbol() , ELseverityLevel::ELsev_info }
76  , { ELinfo.getName() , ELseverityLevel::ELsev_info }
77  , { ELinfo.getInputStr() , ELseverityLevel::ELsev_info }
78  , { ELinfo.getVarName() , ELseverityLevel::ELsev_info }
79  ,
82  , { ELwarning.getInputStr() , ELseverityLevel::ELsev_warning }
83  , { ELwarning.getVarName() , ELseverityLevel::ELsev_warning }
84  ,
85  { ELerror.getSymbol() , ELseverityLevel::ELsev_error }
86  , { ELerror.getName() , ELseverityLevel::ELsev_error }
87  , { ELerror.getInputStr() , ELseverityLevel::ELsev_error }
88  , { ELerror.getVarName() , ELseverityLevel::ELsev_error }
89  ,
94  ,
95  { ELsevere.getSymbol() , ELseverityLevel::ELsev_severe }
96  , { ELsevere.getName() , ELseverityLevel::ELsev_severe }
97  , { ELsevere.getInputStr() , ELseverityLevel::ELsev_severe }
98  , { ELsevere.getVarName() , ELseverityLevel::ELsev_severe }
99  ,
104  } ;
105 
106  return m;
107 
108  }
109 
110 // ----------------------------------------------------------------------
111 // Birth/death:
112 // ----------------------------------------------------------------------
113 
114 ELseverityLevel::ELseverityLevel( enum ELsev_ lev ) : myLevel( lev ) {
115 
116  #ifdef ELsevConTRACE
117  std::cerr << "--- ELseverityLevel " << lev
118  << " (" << getName() << ")\n"
119  << std::flush;
120  #endif
121 
122 }
123 
124 
126 
127  static ELmap const & m = loadMap();
128 
129  ELmap::const_iterator i = m.find( s );
130  myLevel = ( i == m.end() ) ? ELsev_unspecified : i->second;
131 
132 }
133 
135 
136 
137 // ----------------------------------------------------------------------
138 // Comparator:
139 // ----------------------------------------------------------------------
140 
141 int ELseverityLevel::cmp( ELseverityLevel const & e ) const {
142  return myLevel - e.myLevel;
143 }
144 
145 
146 // ----------------------------------------------------------------------
147 // Accessors:
148 // ----------------------------------------------------------------------
149 
151  return myLevel;
152 }
153 
154 
157 
158  switch ( myLevel ) {
159  default : result = "0" ; break;
160  case ELsev_zeroSeverity : result = "--"; break;
161  case ELsev_success : result = "-d"; break; // 4/21/09 mf
162  case ELsev_info : result = "-i"; break;
163  case ELsev_warning : result = "-w"; break;
164  case ELsev_error : result = "-e"; break;
165  case ELsev_unspecified : result = "??"; break;
166  case ELsev_severe : result = "-s"; break;
167  case ELsev_highestSeverity: result = "!!"; break;
168  }; // switch
169 
170  return result;
171 }
172 
173 
176 
177  switch ( myLevel ) {
178  default : result = "?no value?"; break;
179  case ELsev_zeroSeverity : result = "--" ; break;
180  case ELsev_success : result = "Debug" ; break; // 4/21/09 mf
181  case ELsev_info : result = "Info" ; break;
182  case ELsev_warning : result = "Warning" ; break;
183  case ELsev_error : result = "Error" ; break;
184  case ELsev_unspecified : result = "??" ; break;
185  case ELsev_severe : result = "System" ; break; // 6/13/07 mf
186  case ELsev_highestSeverity: result = "!!" ; break;
187  }; // switch
188 
189  return result;
190 }
191 
192 
195 
196  switch ( myLevel ) {
197  default : result = "?no value?" ; break;
198  case ELsev_zeroSeverity : result = "ZERO" ; break;
199  case ELsev_success : result = "DEBUG" ; break;
200  case ELsev_info : result = "INFO" ; break;
201  case ELsev_warning : result = "WARNING" ; break;
202  case ELsev_error : result = "ERROR" ; break;
203  case ELsev_unspecified : result = "UNSPECIFIED"; break;
204  case ELsev_severe : result = "SYSTEM" ; break; // 6/13/07 mf
205  case ELsev_highestSeverity: result = "HIGHEST" ; break;
206  }; // switch
207 
208  return result;
209 }
210 
211 
214 
215  switch ( myLevel ) {
216  default : result = "?no value? "; break;
217  case ELsev_zeroSeverity : result = "ELzeroSeverity "; break;
218  case ELsev_success : result = "ELdebug "; break;// 4/21/09
219  case ELsev_info : result = "ELinfo "; break;
220  case ELsev_warning : result = "ELwarning "; break;
221  case ELsev_error : result = "ELerror "; break;
222  case ELsev_unspecified : result = "ELunspecified "; break;
223  case ELsev_severe : result = "ELsystem "; break;// 6/13/07
224  case ELsev_highestSeverity: result = "ELhighestSeverity"; break;
225  }; // switch
226 
227  return result;
228 }
229 
230 
231 // ----------------------------------------------------------------------
232 // Emitter:
233 // ----------------------------------------------------------------------
234 
235 std::ostream & operator<<( std::ostream & os, const ELseverityLevel & sev ) {
236  return os << " -" << sev.getName() << "- ";
237 }
238 
239 
240 // ----------------------------------------------------------------------
241 // Declare the globally available severity objects,
242 // one generator function and one proxy per non-default ELsev_:
243 // ----------------------------------------------------------------------
244 
247  return e;
248 }
250 
253  return e;
254 }
256 
259  return e;
260 }
262 
265  return e;
266 }
268 
271  return e;
272 }
274 
277  return e;
278 }
280 
283  return e;
284 }
286 
289  return e;
290 }
292 
293 // ----------------------------------------------------------------------
294 
295 
296 } // 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