00001 #ifndef FWCore_MessageService_ErrorLog_h 00002 #define FWCore_MessageService_ErrorLog_h 00003 00004 00005 // ---------------------------------------------------------------------- 00006 // 00007 // ErrorLog provides interface to the module-wide variable by which 00008 // users issue log messages. Both the physicist and the 00009 // frameworker interact with this class, which has a piece 00010 // of module name information, but mainly works thru 00011 // dispatching to the ELadministrator. 00012 // 00013 // 7/6/98 mf Created file. 00014 // 5/2/99 web Added non-default constructor. 00015 // 3/16/00 mf Added operator() (nbytes, data) to invoke ELrecv. 00016 // 6/6/00 web Reflect consolidation of ELadministrator/X; consolidate 00017 // ErrorLog/X. 00018 // 3/13/01 mf hexTrigger and related global methods 00019 // 3/13/01 mf setDiscardThreshold 00020 // 5/7/01 mf operator<< (const char[]) to avoid many instantiations of 00021 // the template one for each length of potential error message 00022 // 3/6/02 mf getELdestControl() 00023 // 12/2/02 mf operator()( int debugLevel ); also 00024 // debugVerbosityLevel, debugSeverityLevel, debugMessageId 00025 // 3/17/04 mf spaceAfterInts 00026 // 00027 // ---------------------------------------------------------------------- 00028 00029 #include "FWCore/MessageLogger/interface/ELstring.h" 00030 #include "FWCore/MessageLogger/interface/ELseverityLevel.h" 00031 #include "FWCore/MessageLogger/interface/ErrorObj.h" 00032 00033 #include <sstream> 00034 00035 namespace edm { 00036 namespace service { 00037 00038 00039 // ---------------------------------------------------------------------- 00040 // Prerequisite classes: 00041 // ---------------------------------------------------------------------- 00042 00043 class ELadministrator; 00044 class ELtsErrorLog; 00045 class ELdestControl; 00046 00047 // ---------------------------------------------------------------------- 00048 // ErrorLog: 00049 // ---------------------------------------------------------------------- 00050 00051 class ErrorLog { 00052 00053 friend class ELtsErrorLog; 00054 00055 public: 00056 00057 // ---------------------------------------------------------------------- 00058 // ----- Methods for physicists logging errors: 00059 // ---------------------------------------------------------------------- 00060 00061 // ----- start a new logging operation: 00062 // 00063 ErrorLog & operator()( const ELseverityLevel & sev, const ELstring & id ); 00064 //-| If overriding this, please see Note 1 00065 //-| at the bottom of this file! 00066 00067 inline ErrorLog & operator()( int debugLevel ); 00068 00069 // ----- mutator: 00070 // 00071 void setSubroutine( const ELstring & subName ); 00072 00073 // ----- logging operations: 00074 // 00075 ErrorLog & operator()( edm::ErrorObj & msg ); // an entire message 00076 00077 ErrorLog & emit( const ELstring & msg ); // just one part of a message 00078 ErrorLog & endmsg(); // no more parts forthcoming 00079 ErrorLog & operator<<( void (* f)(ErrorLog &) );// allow log << zmel::endmsg 00080 00081 // ---------------------------------------------------------------------- 00082 // ----- Methods meant for the Module base class in the framework: 00083 // ---------------------------------------------------------------------- 00084 00085 // ----- birth/death: 00086 // 00087 ErrorLog(); 00088 ErrorLog( const ELstring & pkgName ); 00089 virtual ~ErrorLog(); 00090 00091 // ----- mutators: 00092 // 00093 void setModule ( const ELstring & modName ); // These two are IDENTICAL 00094 void setPackage( const ELstring & pkgName ); // These two are IDENTICAL 00095 00096 // ----- logging collected message: 00097 // 00098 ErrorLog & operator()( int nbytes, char * data ); 00099 00100 // ----- advanced control options: 00101 00102 int setHexTrigger (int trigger); 00103 bool setSpaceAfterInt (bool space=true); 00104 ELseverityLevel setDiscardThreshold (ELseverityLevel sev); 00105 void setDebugVerbosity (int debugVerbosity); 00106 void setDebugMessages (ELseverityLevel sev, ELstring id); 00107 00108 // ----- recovery of an ELdestControl handle 00109 00110 bool getELdestControl (const ELstring & name, 00111 ELdestControl & theDestControl) const; 00112 00113 // ----- information about this ErrorLog instance 00114 00115 ELstring moduleName() const; 00116 ELstring subroutineName() const; 00117 00118 // ----- member data: 00119 // 00120 protected: 00121 ELadministrator * a; 00122 00123 private: 00124 ELstring subroutine; 00125 ELstring module; 00126 public: 00127 int hexTrigger; 00128 bool spaceAfterInt; 00129 ELseverityLevel discardThreshold; 00130 bool discarding; 00131 int debugVerbosityLevel; 00132 ELseverityLevel debugSeverityLevel; 00133 ELstring debugMessageId; 00134 00135 }; // ErrorLog 00136 00137 00138 00139 // ---------------------------------------------------------------------- 00140 // Global functions: 00141 // ---------------------------------------------------------------------- 00142 00143 void endmsg( ErrorLog & log ); 00144 00145 template <class T> 00146 inline ErrorLog & operator<<( ErrorLog & e, const T & t ); 00147 00148 ErrorLog & operator<<( ErrorLog & e, int n ); 00149 ErrorLog & operator<<( ErrorLog & e, long n ); 00150 ErrorLog & operator<<( ErrorLog & e, short n ); 00151 ErrorLog & operator<<( ErrorLog & e, unsigned int n ); 00152 ErrorLog & operator<<( ErrorLog & e, unsigned long n ); 00153 ErrorLog & operator<<( ErrorLog & e, unsigned short n ); 00154 ErrorLog & operator<<( ErrorLog & e, const char s[] ); 00155 00156 // ---------------------------------------------------------------------- 00157 // Macros: 00158 // ---------------------------------------------------------------------- 00159 00160 #define ERRLOG(sev,id) \ 00161 errlog( sev, id ) << __FILE__ <<":" << __LINE__ << " " 00162 00163 #define ERRLOGTO(logname,sev,id) \ 00164 logname( sev, id ) << __FILE__ <<":" << __LINE__ << " " 00165 00166 00167 // ---------------------------------------------------------------------- 00168 00169 00170 } // end of namespace service 00171 } // end of namespace edm 00172 00173 00174 // ---------------------------------------------------------------------- 00175 // .icc 00176 // ---------------------------------------------------------------------- 00177 00178 #define ERRORLOG_ICC 00179 #include "FWCore/MessageService/interface/ErrorLog.icc" 00180 #undef ERRORLOG_ICC 00181 00182 00183 // ---------------------------------------------------------------------- 00184 // Technical Notes 00185 // ---------------------------------------------------------------------- 00186 // 00187 //-| Note 1: Overiding methods that return ErrorLog &: 00188 //-| -------------------------------------------------- 00189 //-| 00190 //-| Both operator() and in the icc file operator<< return ErrorLog& 00191 //-| for chaining purposes. 00192 //-| 00193 //-| Note that these methods are NOT virtual. Derived classes will 00194 //-| only need to override this if they provide non-standard behavior 00195 //-| for the () or << operation. The latter would require tossing out 00196 //-| the template in ErrorLog.cc anyway. 00197 //-| 00198 00199 00200 // ---------------------------------------------------------------------- 00201 00202 00203 #endif // FWCore_MessageService_ErrorLog_h