CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ErrorLog.h
Go to the documentation of this file.
1 #ifndef FWCore_MessageService_ErrorLog_h
2 #define FWCore_MessageService_ErrorLog_h
3 
4 
5 // ----------------------------------------------------------------------
6 //
7 // ErrorLog provides interface to the module-wide variable by which
8 // users issue log messages. Both the physicist and the
9 // frameworker interact with this class, which has a piece
10 // of module name information, but mainly works thru
11 // dispatching to the ELadministrator.
12 //
13 // 7/6/98 mf Created file.
14 // 5/2/99 web Added non-default constructor.
15 // 3/16/00 mf Added operator() (nbytes, data) to invoke ELrecv.
16 // 6/6/00 web Reflect consolidation of ELadministrator/X; consolidate
17 // ErrorLog/X.
18 // 3/13/01 mf hexTrigger and related global methods
19 // 3/13/01 mf setDiscardThreshold
20 // 5/7/01 mf operator<< (const char[]) to avoid many instantiations of
21 // the template one for each length of potential error message
22 // 3/6/02 mf getELdestControl()
23 // 12/2/02 mf operator()( int debugLevel ); also
24 // debugVerbosityLevel, debugSeverityLevel, debugMessageId
25 // 3/17/04 mf spaceAfterInts
26 //
27 // ----------------------------------------------------------------------
28 
32 
33 #include <sstream>
34 
35 namespace edm {
36 namespace service {
37 
38 
39 // ----------------------------------------------------------------------
40 // Prerequisite classes:
41 // ----------------------------------------------------------------------
42 
43 class ELadministrator;
44 class ELtsErrorLog;
45 class ELdestControl;
46 
47 // ----------------------------------------------------------------------
48 // ErrorLog:
49 // ----------------------------------------------------------------------
50 
51 class ErrorLog {
52 
53  friend class ELtsErrorLog;
54 
55 public:
56 
57 // ----------------------------------------------------------------------
58 // ----- Methods for physicists logging errors:
59 // ----------------------------------------------------------------------
60 
61  // ----- start a new logging operation:
62  //
63  ErrorLog & operator()( const ELseverityLevel & sev, const ELstring & id );
64  //-| If overriding this, please see Note 1
65  //-| at the bottom of this file!
66 
67  inline ErrorLog & operator()( int debugLevel );
68 
69  // ----- mutator:
70  //
71  void setSubroutine( const ELstring & subName );
72 
73  // ----- logging operations:
74  //
75  ErrorLog & operator()( edm::ErrorObj & msg ); // an entire message
76 
77  ErrorLog & emitToken( const ELstring & msg ); // just one part of a message
78  ErrorLog & endmsg(); // no more parts forthcoming
79  ErrorLog & operator<<( void (* f)(ErrorLog &) );// allow log << zmel::endmsg
80 
81 // ----------------------------------------------------------------------
82 // ----- Methods meant for the Module base class in the framework:
83 // ----------------------------------------------------------------------
84 
85  // ----- birth/death:
86  //
87  ErrorLog();
88  ErrorLog( const ELstring & pkgName );
89  virtual ~ErrorLog();
90 
91  // ----- mutators:
92  //
93  void setModule ( const ELstring & modName ); // These two are IDENTICAL
94  void setPackage( const ELstring & pkgName ); // These two are IDENTICAL
95 
96  // ----- logging collected message:
97  //
98  ErrorLog & operator()( int nbytes, char * data );
99 
100  // ----- advanced control options:
101 
102  int setHexTrigger (int trigger);
103  bool setSpaceAfterInt (bool space=true);
107 
108  // ----- recovery of an ELdestControl handle
109 
110  bool getELdestControl (const ELstring & name,
111  ELdestControl & theDestControl) const;
112 
113  // ----- information about this ErrorLog instance
114 
115  ELstring moduleName() const;
116  ELstring subroutineName() const;
117 
118  // ----- member data:
119  //
120 protected:
122 
123 private:
126 public:
134 
135 }; // ErrorLog
136 
137 
138 
139 // ----------------------------------------------------------------------
140 // Global functions:
141 // ----------------------------------------------------------------------
142 
143 void endmsg( ErrorLog & log );
144 
145 template <class T>
146 inline ErrorLog & operator<<( ErrorLog & e, const T & t );
147 
148 ErrorLog & operator<<( ErrorLog & e, int n );
149 ErrorLog & operator<<( ErrorLog & e, long n );
150 ErrorLog & operator<<( ErrorLog & e, short n );
151 ErrorLog & operator<<( ErrorLog & e, unsigned int n );
152 ErrorLog & operator<<( ErrorLog & e, unsigned long n );
153 ErrorLog & operator<<( ErrorLog & e, unsigned short n );
154 ErrorLog & operator<<( ErrorLog & e, const char s[] );
155 
156 // ----------------------------------------------------------------------
157 // Macros:
158 // ----------------------------------------------------------------------
159 
160 #define ERRLOG(sev,id) \
161  errlog( sev, id ) << __FILE__ <<":" << __LINE__ << " "
162 
163 #define ERRLOGTO(logname,sev,id) \
164  logname( sev, id ) << __FILE__ <<":" << __LINE__ << " "
165 
166 
167 // ----------------------------------------------------------------------
168 
169 
170 } // end of namespace service
171 } // end of namespace edm
172 
173 
174 // ----------------------------------------------------------------------
175 // .icc
176 // ----------------------------------------------------------------------
177 
178 #define ERRORLOG_ICC
179  #include "FWCore/MessageService/interface/ErrorLog.icc"
180 #undef ERRORLOG_ICC
181 
182 
183 // ----------------------------------------------------------------------
184 // Technical Notes
185 // ----------------------------------------------------------------------
186 //
187 //-| Note 1: Overiding methods that return ErrorLog &:
188 //-| --------------------------------------------------
189 //-|
190 //-| Both operator() and in the icc file operator<< return ErrorLog&
191 //-| for chaining purposes.
192 //-|
193 //-| Note that these methods are NOT virtual. Derived classes will
194 //-| only need to override this if they provide non-standard behavior
195 //-| for the () or << operation. The latter would require tossing out
196 //-| the template in ErrorLog.cc anyway.
197 //-|
198 
199 
200 // ----------------------------------------------------------------------
201 
202 
203 #endif // FWCore_MessageService_ErrorLog_h
void setModule(const ELstring &modName)
Definition: ErrorLog.cc:236
bool setSpaceAfterInt(bool space=true)
Definition: ErrorLog.cc:314
ErrorLog & endmsg()
Definition: ErrorLog.cc:289
bool getELdestControl(const ELstring &name, ELdestControl &theDestControl) const
Definition: ErrorLog.cc:341
void setPackage(const ELstring &pkgName)
Definition: ErrorLog.cc:243
ErrorLog & operator()(const ELseverityLevel &sev, const ELstring &id)
Definition: ErrorLog.cc:116
void endmsg(ErrorLog &log)
Definition: ErrorLog.cc:357
ErrorLog & operator<<(void(*f)(ErrorLog &))
Definition: ErrorLog.cc:257
ELseverityLevel setDiscardThreshold(ELseverityLevel sev)
Definition: ErrorLog.cc:326
void setDebugMessages(ELseverityLevel sev, ELstring id)
Definition: ErrorLog.cc:336
ELseverityLevel discardThreshold
Definition: ErrorLog.h:129
ErrorLog & emitToken(const ELstring &msg)
Definition: ErrorLog.cc:269
void setSubroutine(const ELstring &subName)
Definition: ErrorLog.cc:149
double f[11][100]
void setDebugVerbosity(int debugVerbosity)
Definition: ErrorLog.cc:332
ELstring subroutineName() const
Definition: ErrorLog.cc:351
ErrorLog & operator<<(ErrorLog &e, const T &t)
ELseverityLevel debugSeverityLevel
Definition: ErrorLog.h:132
ELstring moduleName() const
Definition: ErrorLog.cc:350
int setHexTrigger(int trigger)
Definition: ErrorLog.cc:320
ELadministrator * a
Definition: ErrorLog.h:121
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
ELstring debugMessageId
Definition: ErrorLog.h:133
long double T
std::string ELstring
Definition: ELstring.h:26