Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #include "FWCore/MessageLogger/interface/ErrorObj.h"
00046
00047 #ifndef IOSTREAM_INCLUDED
00048 #endif
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 namespace edm
00064 {
00065
00066
00067
00068
00069
00070
00071 int ErrorObj::ourSerial( 0 );
00072 const unsigned int maxIDlength( 200 );
00073
00074
00075
00076
00077
00078
00079 ErrorObj::ErrorObj( const ELseverityLevel & sev,
00080 const ELstring & id,
00081 bool verbat ) : verbatim(verbat) {
00082
00083 #ifdef ErrorObjCONSTRUCTOR_TRACE
00084 std::cerr << "Constructor for ErrorObj\n";
00085 #endif
00086
00087 clear();
00088 set( sev, id );
00089
00090 }
00091
00092
00093 ErrorObj::ErrorObj( const ErrorObj & orig ) :
00094 mySerial ( orig.mySerial )
00095 , myXid ( orig.myXid )
00096 , myIdOverflow ( orig.myIdOverflow )
00097 , myTimestamp ( orig.myTimestamp )
00098 , myItems ( orig.myItems )
00099 , myReactedTo ( orig.myReactedTo )
00100 , myOs ( )
00101 , emptyString ( )
00102 , verbatim ( orig.verbatim )
00103 {
00104
00105 #ifdef ErrorObjCONSTRUCTOR_TRACE
00106 std::cerr << "Copy Constructor for ErrorObj\n";
00107 #endif
00108
00109 }
00110
00111
00112 ErrorObj::~ErrorObj() {
00113
00114 #ifdef ErrorObjCONSTRUCTOR_TRACE
00115 std::cerr << "Destructor for ErrorObj\n";
00116 #endif
00117
00118 }
00119
00120
00121
00122
00123
00124
00125 int ErrorObj::serial() const { return mySerial; }
00126 const ELextendedID & ErrorObj::xid() const { return myXid; }
00127 const ELstring & ErrorObj::idOverflow() const { return myIdOverflow; }
00128 time_t ErrorObj::timestamp() const { return myTimestamp; }
00129 const ELlist_string & ErrorObj::items() const { return myItems; }
00130 bool ErrorObj::reactedTo() const { return myReactedTo; }
00131 bool ErrorObj::is_verbatim()const { return verbatim; }
00132
00133 ELstring ErrorObj::context() const {
00134 return myContext;
00135 }
00136
00137 ELstring ErrorObj::fullText() const {
00138
00139 ELstring result;
00140 for ( ELlist_string::const_iterator it = myItems.begin();
00141 it != myItems.end();
00142 ++it )
00143 result += *it;
00144 return result;
00145
00146 }
00147
00148
00149
00150
00151
00152
00153 void ErrorObj::setSeverity( const ELseverityLevel & sev ) {
00154 myXid.severity = (sev <= ELzeroSeverity ) ? (ELseverityLevel)ELincidental
00155 : (sev >= ELhighestSeverity) ? (ELseverityLevel)ELfatal
00156 : sev
00157 ;
00158 }
00159
00160
00161 void ErrorObj::setID( const ELstring & id ) {
00162 myXid.id = ELstring( id, 0, maxIDlength );
00163 if ( id.length() > maxIDlength )
00164 myIdOverflow = ELstring( id, maxIDlength, id.length()-maxIDlength );
00165 }
00166
00167
00168 void ErrorObj::setModule( const ELstring & module ) { myXid.module = module; }
00169
00170 void ErrorObj::setContext( const ELstring & c ) { myContext = c; }
00171
00172
00173 void ErrorObj::setSubroutine( const ELstring & subroutine ) {
00174 #ifdef ErrorObj_SUB_TRACE
00175 std::cerr << "=:=:=: ErrorObj::setSubroutine(" << subroutine << ")\n";
00176 #endif
00177 myXid.subroutine = (subroutine[0] == ' ')
00178 ? subroutine.substr(1)
00179 : subroutine;
00180 }
00181
00182
00183 void ErrorObj::setProcess( const ELstring & proc ) {
00184 myXid.process = proc;
00185 #if 0
00186 std::cerr << "ErrorObj process set to \"" << proc << "\"\n";
00187 #endif
00188 }
00189
00190 void ErrorObj::setReactedTo( bool r ) {
00191 myReactedTo = r;
00192 }
00193
00194
00195 #ifdef ErrorObj_SUB_TRACE
00196 static int subN = 0;
00197 #endif
00198
00199
00200 ErrorObj & ErrorObj::emitToken( const ELstring & s ) {
00201
00202 #ifdef ErrorObj_EMIT_TRACE
00203 std::cerr << "=:=:=: ErrorObj::emitToken( " << s << " )\n";
00204 #endif
00205
00206 #ifdef ErrorObj_SUB_TRACE
00207 if ( subN > 0 ) {
00208 std::cerr << "=:=:=: subN ErrorObj::emitToken( " << s << " )\n";
00209 subN--;
00210 }
00211 #endif
00212
00213 if ( eq_nocase(s.substr(0,5), "@SUB=" ) ) {
00214 #ifdef ErrorObj_SUB_TRACE
00215 std::cerr << "=:=:=: ErrorObj::@SUB s.substr(5) is: " << s.substr(5)
00216 << '\n';
00217 #endif
00218 setSubroutine(s.substr(5));
00219 }
00220 else {
00221 myItems.push_back( s );
00222 }
00223
00224 return * this;
00225
00226 }
00227
00228
00229 void ErrorObj::set( const ELseverityLevel & sev, const ELstring & id ) {
00230
00231 clear();
00232
00233 myTimestamp = time( 0 );
00234 mySerial = ++ ourSerial;
00235
00236 setID( id );
00237 setSeverity( sev );
00238
00239 }
00240
00241
00242 void ErrorObj::clear() {
00243
00244 mySerial = 0;
00245 myXid.clear();
00246 myIdOverflow = "";
00247 myTimestamp = 0;
00248 myItems.erase( myItems.begin(), myItems.end() );
00249 myReactedTo = false;
00250
00251 }
00252
00253 ErrorObj &
00254 ErrorObj::opltlt ( const char s[] ) {
00255
00256
00257
00258 myOs.str(emptyString);
00259 myOs << s;
00260 #ifdef OLD_STYLE_AUTOMATIC_SPACES
00261 if ( ! myOs.str().empty() ) {
00262 if ( !verbatim ) {
00263 emitToken( myOs.str() + ' ' );
00264 } else {
00265 emitToken( myOs.str() );
00266 }
00267 }
00268 #else
00269 if ( ! myOs.str().empty() ) emitToken( myOs.str() );
00270 #endif
00271 return *this;
00272 }
00273
00274 ErrorObj & operator<<( ErrorObj & e, const char s[] ) {
00275 return e.opltlt(s);
00276 }
00277
00278 }