00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "FWCore/MessageService/interface/ELfwkJobReport.h"
00023 #include "FWCore/MessageLogger/interface/ErrorObj.h"
00024 #include "FWCore/Utilities/interface/do_nothing_deleter.h"
00025
00026
00027
00028
00029
00030
00031 #include <iostream>
00032 #include <fstream>
00033
00034 namespace edm {
00035 namespace service {
00036
00037
00038
00039
00040
00041 ELfwkJobReport::ELfwkJobReport()
00042 : ELdestination ( )
00043 , os ( &std::cerr, do_nothing_deleter() )
00044 , charsOnLine ( 0 )
00045 , xid ( )
00046 , wantTimestamp ( true )
00047 , wantModule ( true )
00048 , wantSubroutine ( true )
00049 , wantText ( true )
00050 , wantSomeContext ( true )
00051 , wantSerial ( false )
00052 , wantFullContext ( false )
00053 , wantTimeSeparate ( false )
00054 , wantEpilogueSeparate( false )
00055 {
00056
00057 #ifdef ELfwkJobReportCONSTRUCTOR_TRACE
00058 std::cerr << "Constructor for ELfwkJobReport()\n";
00059 #endif
00060
00061
00062 emitToken( "<FrameworkJobReport>\n", true );
00063
00064 }
00065
00066
00067 ELfwkJobReport::ELfwkJobReport( std::ostream & os_ , bool )
00068 : ELdestination ( )
00069 , os ( &os_, do_nothing_deleter() )
00070 , charsOnLine ( 0 )
00071 , xid ( )
00072 , wantTimestamp ( true )
00073 , wantModule ( true )
00074 , wantSubroutine ( true )
00075 , wantText ( true )
00076 , wantSomeContext ( true )
00077 , wantSerial ( false )
00078 , wantFullContext ( false )
00079 , wantTimeSeparate ( false )
00080 , wantEpilogueSeparate( false )
00081 {
00082
00083 #ifdef ELfwkJobReportCONSTRUCTOR_TRACE
00084 std::cerr << "Constructor for ELfwkJobReport( os )\n";
00085 #endif
00086
00087
00088 emitToken( "<FrameworkJobReport>\n\n", true );
00089
00090 }
00091
00092
00093 ELfwkJobReport::ELfwkJobReport( const ELstring & fileName, bool )
00094 : ELdestination ( )
00095 , os ( new std::ofstream( fileName.c_str() , std::ios::app), close_and_delete())
00096 , charsOnLine ( 0 )
00097 , xid ( )
00098 , wantTimestamp ( true )
00099 , wantModule ( true )
00100 , wantSubroutine ( true )
00101 , wantText ( true )
00102 , wantSomeContext ( true )
00103 , wantSerial ( false )
00104 , wantFullContext ( false )
00105 , wantTimeSeparate ( false )
00106 , wantEpilogueSeparate( false )
00107 {
00108
00109 #ifdef ELfwkJobReportCONSTRUCTOR_TRACE
00110 std::cerr << "Constructor for ELfwkJobReport( " << fileName << " )\n";
00111 #endif
00112
00113 if ( os && *os ) {
00114 #ifdef ELfwkJobReportCONSTRUCTOR_TRACE
00115 std::cerr << " Testing if os is owned\n";
00116 #endif
00117 #ifdef ELfwkJobReportCONSTRUCTOR_TRACE
00118 std::cerr << " About to do first emit\n";
00119 #endif
00120
00121 emitToken( "<FrameworkJobReport>\n");
00122 } else {
00123 #ifdef ELfwkJobReportCONSTRUCTOR_TRACE
00124 std::cerr << " Deleting os\n";
00125 #endif
00126 os.reset(&std::cerr, do_nothing_deleter());
00127 #ifdef ELfwkJobReportCONSTRUCTOR_TRACE
00128 std::cerr << " about to emit to cerr\n";
00129 #endif
00130
00131 emitToken( "<FrameworkJobReport>\n\n" );
00132 }
00133
00134 #ifdef ELfwkJobReportCONSTRUCTOR_TRACE
00135 std::cerr << "Constructor for ELfwkJobReport completed.\n";
00136 #endif
00137
00138 }
00139
00140
00141 ELfwkJobReport::ELfwkJobReport( const ELfwkJobReport & orig )
00142 : ELdestination ( )
00143 , os ( orig.os )
00144 , charsOnLine ( orig.charsOnLine )
00145 , xid ( orig.xid )
00146 , wantTimestamp ( orig.wantTimestamp )
00147 , wantModule ( orig.wantModule )
00148 , wantSubroutine ( orig.wantSubroutine )
00149 , wantText ( orig.wantText )
00150 , wantSomeContext ( orig.wantSomeContext )
00151 , wantSerial ( orig.wantSerial )
00152 , wantFullContext ( orig.wantFullContext )
00153 , wantTimeSeparate ( orig.wantTimeSeparate )
00154 , wantEpilogueSeparate( orig.wantEpilogueSeparate )
00155 {
00156
00157 #ifdef ELfwkJobReportCONSTRUCTOR_TRACE
00158 std::cerr << "Copy constructor for ELfwkJobReport\n";
00159 #endif
00160
00161
00162 threshold = orig.threshold;
00163 traceThreshold = orig.traceThreshold;
00164 limits = orig.limits;
00165 preamble = orig.preamble;
00166 newline = orig.newline;
00167 indent = orig.indent;
00168 lineLength = orig.lineLength;
00169
00170 ignoreMostModules = orig.ignoreMostModules;
00171 respondToThese = orig.respondToThese;
00172 respondToMostModules = orig.respondToMostModules;
00173 ignoreThese = orig.ignoreThese;
00174
00175 }
00176
00177
00178 ELfwkJobReport::~ELfwkJobReport() {
00179
00180 #ifdef ELfwkJobReportCONSTRUCTOR_TRACE
00181 std::cerr << "Destructor for ELfwkJobReport\n";
00182 #endif
00183 }
00184
00185
00186
00187
00188
00189
00190 ELfwkJobReport *
00191 ELfwkJobReport::clone() const {
00192
00193 return new ELfwkJobReport( *this );
00194
00195 }
00196
00197
00198 bool ELfwkJobReport::log( const edm::ErrorObj & msg ) {
00199
00200 #ifdef ELfwkJobReportTRACE_LOG
00201 std::cerr << " =:=:=: Log to an ELfwkJobReport \n";
00202 #endif
00203
00204 xid = msg.xid();
00205
00206
00207 if (xid.id != "FwkJob") return false;
00208
00209
00210
00211
00212
00213 if ( msg.xid().severity < threshold ) return false;
00214
00215 if ( (xid.id == "BeginningJob") ||
00216 (xid.id == "postBeginJob") ||
00217 (xid.id == "preEventProcessing") ||
00218 (xid.id == "preModule") ||
00219 (xid.id == "postModule") ||
00220 (xid.id == "postEventProcessing") ||
00221 (xid.id == "postEndJob") ) return false;
00222 if ( thisShouldBeIgnored(xid.module) ) return false;
00223 if ( ! limits.add( msg.xid() ) ) return false;
00224
00225 #ifdef ELfwkJobReportTRACE_LOG
00226 std::cerr << " =:=:=: Limits table work done \n";
00227 #endif
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 #ifdef ELfwkJobReportTRACE_LOG
00243 std::cerr << " =:=:=: Prologue done \n";
00244 #endif
00245
00246
00247
00248 if ( wantText ) {
00249 ELlist_string::const_iterator it;
00250 for ( it = msg.items().begin(); it != msg.items().end(); ++it ) {
00251 #ifdef ELfwkJobReportTRACE_LOG
00252 std::cerr << " =:=:=: Item: " << *it << '\n';
00253 #endif
00254
00255 emitToken( *it);
00256 emitToken( "\n" );
00257
00258 }
00259 }
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 #ifdef ELfwkJobReportTRACE_LOG
00271 std::cerr << " =:=:=: Module done \n";
00272 #endif
00273
00274
00275
00276
00277
00278 #ifdef ELfwkJobReportTRACE_LOG
00279 std::cerr << " =:=:=: log(msg) done: \n";
00280 #endif
00281
00282 return true;
00283
00284 }
00285
00286 void ELfwkJobReport::finish() {
00287
00288 (*os) << "</FrameworkJobReport>\n";
00289 }
00290
00291
00292
00293
00294
00295
00296
00297
00298 void ELfwkJobReport::emitToken( const ELstring & s, bool ) {
00299
00300 #ifdef ELfwkJobReport_EMIT_TRACE
00301 std::cerr << "[][][] in emit: charsOnLine is " << charsOnLine << '\n';
00302 std::cerr << "[][][] in emit: s.length() " << s.length() << '\n';
00303 std::cerr << "[][][] in emit: lineLength is " << lineLength << '\n';
00304 #endif
00305
00306 if (s.length() == 0) {
00307 return;
00308 }
00309
00310 #ifdef ELfwkJobReport_EMIT_TRACE
00311 std::cerr << "[][][] in emit: about to << s to *os: " << s << " \n";
00312 #endif
00313
00314 (*os) << s;
00315
00316 #ifdef ELfwkJobReport_EMIT_TRACE
00317 std::cerr << "[][][] in emit: completed \n";
00318 #endif
00319
00320 }
00321
00322
00323
00324
00325
00326
00327 void ELfwkJobReport::includeTime() { wantTimestamp = true; }
00328 void ELfwkJobReport::suppressTime() { wantTimestamp = false; }
00329
00330 void ELfwkJobReport::includeModule() { wantModule = true; }
00331 void ELfwkJobReport::suppressModule() { wantModule = false; }
00332
00333 void ELfwkJobReport::includeSubroutine() { wantSubroutine = true; }
00334 void ELfwkJobReport::suppressSubroutine() { wantSubroutine = false; }
00335
00336 void ELfwkJobReport::includeText() { wantText = true; }
00337 void ELfwkJobReport::suppressText() { wantText = false; }
00338
00339 void ELfwkJobReport::includeContext() { wantSomeContext = true; }
00340 void ELfwkJobReport::suppressContext() { wantSomeContext = false; }
00341
00342 void ELfwkJobReport::suppressSerial() { wantSerial = false; }
00343 void ELfwkJobReport::includeSerial() { wantSerial = true; }
00344
00345 void ELfwkJobReport::useFullContext() { wantFullContext = true; }
00346 void ELfwkJobReport::useContext() { wantFullContext = false; }
00347
00348 void ELfwkJobReport::separateTime() { wantTimeSeparate = true; }
00349 void ELfwkJobReport::attachTime() { wantTimeSeparate = false; }
00350
00351 void ELfwkJobReport::separateEpilogue() { wantEpilogueSeparate = true; }
00352 void ELfwkJobReport::attachEpilogue() { wantEpilogueSeparate = false; }
00353
00354
00355
00356
00357
00358
00359 void ELfwkJobReport::summarization(
00360 const ELstring & fullTitle
00361 , const ELstring & sumLines
00362 ) {
00363 const int titleMaxLength( 40 );
00364
00365
00366
00367 ELstring title( fullTitle, 0, titleMaxLength );
00368 int q = (lineLength - title.length() - 2) / 2;
00369 ELstring line(q, '=');
00370 emitToken( "", true );
00371 emitToken( line );
00372 emitToken( " " );
00373 emitToken( title );
00374 emitToken( " " );
00375 emitToken( line, true );
00376
00377
00378
00379 *os << sumLines;
00380
00381
00382
00383 emitToken( "", true );
00384 emitToken( ELstring(lineLength, '='), true );
00385
00386 }
00387
00388
00389
00390
00391
00392
00393 void ELfwkJobReport::changeFile (std::ostream & os_) {
00394 os.reset(&os_, do_nothing_deleter());
00395 emitToken( "\n=======================================================", true );
00396 emitToken( "\nError Log changed to this stream\n" );
00397 emitToken( "\n=======================================================\n", true );
00398 }
00399
00400 void ELfwkJobReport::changeFile (const ELstring & filename) {
00401 os.reset(new std::ofstream( filename.c_str(), std::ios::app ), close_and_delete());
00402 emitToken( "\n=======================================================", true );
00403 emitToken( "\nError Log changed to this file\n" );
00404 emitToken( "\n=======================================================\n", true );
00405 }
00406
00407 void ELfwkJobReport::flush() {
00408 os->flush();
00409 }
00410
00411
00412
00413
00414
00415 }
00416 }