CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/FWCore/MessageService/src/ELoutput.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 //
00003 // ELoutput.cc
00004 //
00005 //
00006 // 7/8/98       mf      Created
00007 // 6/10/99      jv      JV:1 puts a \n after each log using suppressContext()
00008 // 6/11/99      jv      JV:2 accounts for newline at the beginning and end of
00009 //                           an emitted ELstring
00010 // 6/14/99      mf      Made the static char* in formatTime into auto so that
00011 //                      ctime(&t) is called each time - corrects the bug of
00012 //                      never changing the first timestamp.
00013 // 6/15/99      mf      Inserted operator<<(void (*f)(ErrorLog&) to avoid
00014 //                      mystery characters being inserted when users <<
00015 //                      endmsg to an ErrorObj.
00016 // 7/2/99       jv      Added separate/attachTime, Epilogue, and Serial options
00017 // 8/2/99       jv      Modified handling of newline in an emmitted ELstring
00018 // 2/22/00      mf      Changed usage of myDestX to myOutputX.  Added
00019 //                      constructor of ELoutput from ELoutputX * to allow for
00020 //                      inheritance.
00021 // 6/7/00       web     Reflect consolidation of ELdestination/X; consolidate
00022 //                      ELoutput/X; add filterModule() and query logic
00023 // 10/4/00      mf      excludeModule()
00024 // 1/15/01      mf      line length control: changed ELoutputLineLen to
00025 //                      the base class lineLen (no longer static const)
00026 // 2/13/01      mf      Added emitAtStart argument to two constructors
00027 //                      { Enh 001 }.
00028 // 4/4/01       mf      Simplify filter/exclude logic by useing base class
00029 //                      method thisShouldBeIgnored().  Eliminate
00030 //                      moduleOfinterest and moduleToexclude.
00031 // 6/15/01      mf      Repaired Bug 005 by explicitly setting all
00032 //                      ELdestination member data appropriately.
00033 //10/18/01      mf      When epilogue not on separate line, preceed by space
00034 // 6/23/03      mf      changeFile(), flush()
00035 // 4/09/04      mf      Add 1 to length in strftime call in formatTime, to
00036 //                      correctly provide the time zone.  Had been providing
00037 //                      CST every time.
00038 //
00039 // 12/xx/06     mf      Tailoring to CMS MessageLogger 
00040 //  1/11/06     mf      Eliminate time stamp from starting message 
00041 //  3/20/06     mf      Major formatting change to do no formatting
00042 //                      except the header and line separation.
00043 //  4/04/06     mf      Move the line feed between header and text
00044 //                      till after the first 3 items (FILE:LINE) for
00045 //                      debug messages. 
00046 //  6/06/06     mf      Verbatim
00047 //  6/12/06     mf      Set preambleMode true when printing the header
00048 //
00049 // Change Log
00050 //
00051 //  1 10/18/06  mf      In format_time(): Initialized ts[] with 5 extra
00052 //                      spaces, to cover cases where time zone is more than
00053 //                      3 characters long
00054 //
00055 //  2 10/30/06  mf      In log():  if severity indicated is SEVERE, do not
00056 //                      impose limits.  This is to implement the LogSystem
00057 //                      feature:  Those messages are never to be ignored.
00058 //
00059 //  3 6/11/07  mf       In emitToken():  In preamble mode, do not break and indent 
00060 //                      even if exceeding nominal line length.
00061 //
00062 //  4 6/11/07  mf       In log():  After the message, add a %MSG on its own line 
00063 //
00064 //  5 3/27/09  mf       Properly treat charsOnLine, which had been fouled due to
00065 //                      change 3.  In log() and emitToken().
00066 //
00067 //  6 9/2/10  mf        Initialize preambleMode in each ctor, and remove the
00068 //                      unnecessary use of tprm which was preserving a moot 
00069 //                      initial value.
00070 //
00071 //  7 9/30/10 wmtan     make formatTime() thread safe by not using statics.
00072 //
00073 // ----------------------------------------------------------------------
00074 
00075 
00076 #include "FWCore/MessageService/interface/ELoutput.h"
00077 #include "FWCore/MessageService/interface/ELadministrator.h"
00078 #include "FWCore/MessageService/interface/ELcontextSupplier.h"
00079 
00080 #include "FWCore/MessageLogger/interface/ErrorObj.h"
00081 
00082 #include "FWCore/Utilities/interface/do_nothing_deleter.h"
00083 
00084 // Possible Traces:
00085 // #define ELoutputCONSTRUCTOR_TRACE
00086 // #define ELoutputTRACE_LOG
00087 // #define ELoutput_EMIT_TRACE
00088 
00089 #include <iostream>
00090 #include <fstream>
00091 #include <cstring>
00092 
00093 namespace edm {
00094 namespace service {
00095 
00096 // ----------------------------------------------------------------------
00097 // Useful function:
00098 // ----------------------------------------------------------------------
00099 
00100 
00101 static ELstring formatTime( const time_t t )  { // Change log 7
00102 
00103   static char const dummy[] = "dd-Mon-yyyy hh:mm:ss TZN     "; // Change log 7 for length only
00104   char ts[sizeof(dummy)]; // Change log 7
00105 
00106   struct tm timebuf; // Change log 7
00107 
00108   strftime( ts, sizeof(dummy), "%d-%b-%Y %H:%M:%S %Z", localtime_r(&t, &timebuf) ); // Change log 7
00109                 // mf 4-9-04
00110 
00111 #ifdef STRIP_TRAILING_BLANKS_IN_TIMEZONE
00112   // strip trailing blanks that would come when the time zone is not as
00113   // long as the maximum allowed - probably not worth the time 
00114   unsigned int b = strlen(ts);
00115   while (ts[--b] == ' ') {ts[b] = 0;}
00116 #endif 
00117 
00118   ELstring result(ts); // Change log 7
00119   return result; // Change log 7
00120 }  // formatTime()
00121 
00122 
00123 // ----------------------------------------------------------------------
00124 // Constructors:
00125 // ----------------------------------------------------------------------
00126 
00127 ELoutput::ELoutput()
00128 : ELdestination       (            )
00129 , os                  ( &std::cerr, do_nothing_deleter() )
00130 , charsOnLine         ( 0          )
00131 , xid                 (            )
00132 , wantTimestamp       ( true       )
00133 , wantModule          ( true       )
00134 , wantSubroutine      ( true       )
00135 , wantText            ( true       )
00136 , wantSomeContext     ( true       )
00137 , wantSerial          ( false      )
00138 , wantFullContext     ( false      )
00139 , wantTimeSeparate    ( false      )
00140 , wantEpilogueSeparate( false      )
00141 , preambleMode        ( true       )            // 006 9/2/10 mf
00142 {
00143 
00144   #ifdef ELoutputCONSTRUCTOR_TRACE
00145     std::cerr << "Constructor for ELoutput()\n";
00146   #endif
00147 
00148   emitToken( "\n=================================================", true );
00149   emitToken( "\nMessage Log File written by MessageLogger service \n" );
00150   emitToken( "\n=================================================\n", true );
00151 
00152 }  // ELoutput()
00153 
00154 
00155 ELoutput::ELoutput( std::ostream & os_ , bool emitAtStart )
00156 : ELdestination       (       )
00157 , os                  ( &os_, do_nothing_deleter() )
00158 , charsOnLine         ( 0     )
00159 , xid                 (       )
00160 , wantTimestamp       ( true  )
00161 , wantModule          ( true  )
00162 , wantSubroutine      ( true  )
00163 , wantText            ( true  )
00164 , wantSomeContext     ( true  )
00165 , wantSerial          ( false )
00166 , wantFullContext     ( false )
00167 , wantTimeSeparate    ( false )
00168 , wantEpilogueSeparate( false )
00169 , preambleMode        ( true  )         // 006 9/2/10 mf
00170 {
00171 
00172   #ifdef ELoutputCONSTRUCTOR_TRACE
00173     std::cerr << "Constructor for ELoutput( os )\n";
00174   #endif
00175 
00176                                         // Enh 001 2/13/01 mf
00177   if (emitAtStart) {
00178     preambleMode = true;
00179     emitToken( "\n=================================================", true );
00180     emitToken( "\nMessage Log File written by MessageLogger service \n" );
00181     emitToken( "\n=================================================\n", true );
00182   }
00183 
00184 }  // ELoutput()
00185 
00186 
00187 ELoutput::ELoutput( const ELstring & fileName, bool emitAtStart )
00188 : ELdestination       (       )
00189 , os                  ( new std::ofstream( fileName.c_str() , std::ios/*_base*/::app), close_and_delete())
00190 , charsOnLine         ( 0     )
00191 , xid                 (       )
00192 , wantTimestamp       ( true  )
00193 , wantModule          ( true  )
00194 , wantSubroutine      ( true  )
00195 , wantText            ( true  )
00196 , wantSomeContext     ( true  )
00197 , wantSerial          ( false )
00198 , wantFullContext     ( false )
00199 , wantTimeSeparate    ( false )
00200 , wantEpilogueSeparate( false )
00201 , preambleMode        ( true  )         // 006 9/2/10 mf
00202 {
00203 
00204   #ifdef ELoutputCONSTRUCTOR_TRACE
00205     std::cerr << "Constructor for ELoutput( " << fileName << " )\n";
00206   #endif
00207 
00208   preambleMode = true;
00209   if ( os && *os )  {
00210     #ifdef ELoutputCONSTRUCTOR_TRACE
00211       std::cerr << "          Testing if os is owned\n";
00212     #endif
00213     #ifdef ELoutputCONSTRUCTOR_TRACE
00214       std::cerr << "          About to do first emit\n";
00215     #endif
00216                                         // Enh 001 2/13/01 mf
00217     if (emitAtStart) {
00218       emitToken( "\n=======================================================",
00219                                                                 true );
00220       emitToken( "\nError Log File " );
00221       emitToken( fileName );
00222       emitToken( " \n" );
00223     }
00224   }
00225   else  {
00226     #ifdef ELoutputCONSTRUCTOR_TRACE
00227       std::cerr << "          Deleting os\n";
00228     #endif
00229     os.reset(&std::cerr, do_nothing_deleter());
00230     #ifdef ELoutputCONSTRUCTOR_TRACE
00231       std::cerr << "          about to emit to cerr\n";
00232     #endif
00233     if (emitAtStart) {
00234       emitToken( "\n=======================================================",
00235                                                                 true );
00236       emitToken( "\n%MSG** Logging to cerr is being substituted" );
00237       emitToken( " for specified log file \"" );
00238       emitToken( fileName  );
00239       emitToken( "\" which could not be opened for write or append.\n" );
00240     }
00241   }
00242   if (emitAtStart) {
00243     ELstring const& ftime = formatTime(time(0)); // Change log 7
00244     emitToken( ftime, true );
00245     emitToken( "\n=======================================================\n",
00246                                                                 true );
00247   }
00248   // preambleMode = tprm; removed 9/2/10 mf see change log 6
00249 
00250   #ifdef ELoutputCONSTRUCTOR_TRACE
00251     std::cerr << "Constructor for ELoutput completed.\n";
00252   #endif
00253 
00254 }  // ELoutput()
00255 
00256 
00257 ELoutput::ELoutput( const ELoutput & orig )
00258 : ELdestination       (                           )
00259 , os                  ( orig.os                   )
00260 , charsOnLine         ( orig.charsOnLine          )
00261 , xid                 ( orig.xid                  )
00262 , wantTimestamp       ( orig.wantTimestamp        )
00263 , wantModule          ( orig.wantModule           )
00264 , wantSubroutine      ( orig.wantSubroutine       )
00265 , wantText            ( orig.wantText             )
00266 , wantSomeContext     ( orig.wantSomeContext      )
00267 , wantSerial          ( orig.wantSerial           )
00268 , wantFullContext     ( orig.wantFullContext      )
00269 , wantTimeSeparate    ( orig.wantTimeSeparate     )
00270 , wantEpilogueSeparate( orig.wantEpilogueSeparate )
00271 , preambleMode        ( orig.preambleMode         )     // 006 9/2/10 mf
00272 {
00273 
00274   #ifdef ELoutputCONSTRUCTOR_TRACE
00275     std::cerr << "Copy constructor for ELoutput\n";
00276   #endif
00277 
00278   // mf 6/15/01 fix of Bug 005
00279   threshold             = orig.threshold;
00280   traceThreshold        = orig.traceThreshold;
00281   limits                = orig.limits;
00282   preamble              = orig.preamble;
00283   newline               = orig.newline;
00284   indent                = orig.indent;
00285   lineLength            = orig.lineLength;
00286 
00287   ignoreMostModules     = orig.ignoreMostModules;
00288   respondToThese        = orig.respondToThese;
00289   respondToMostModules  = orig.respondToMostModules;
00290   ignoreThese           = orig.ignoreThese;
00291 
00292 }  // ELoutput()
00293 
00294 
00295 ELoutput::~ELoutput()  {
00296 
00297   #ifdef ELoutputCONSTRUCTOR_TRACE
00298     std::cerr << "Destructor for ELoutput\n";
00299   #endif
00300 
00301 }  // ~ELoutput()
00302 
00303 
00304 // ----------------------------------------------------------------------
00305 // Methods invoked by the ELadministrator:
00306 // ----------------------------------------------------------------------
00307 
00308 ELoutput *
00309 ELoutput::clone() const  {
00310 
00311   return new ELoutput( *this );
00312 
00313 } // clone()
00314 
00315 //#define THRESHTRACE
00316 //#define ELoutputTRACE_LOG
00317 
00318 bool ELoutput::log( const edm::ErrorObj & msg )  {
00319 
00320   #ifdef ELoutputTRACE_LOG
00321     std::cerr << "    =:=:=: Log to an ELoutput \n";
00322   #endif
00323 
00324   xid = msg.xid();      // Save the xid.
00325 
00326 #ifdef THRESHTRACE
00327   std::cerr << "    =:=:=: Log to an ELoutput \n"
00328             << "           severity  = " << xid.severity  << "\n"
00329             << "           threshold = " << threshold     << "\n"
00330             << "           id        = " << xid.id        << "\n";
00331 #endif
00332 
00333   // See if this message is to be acted upon, and add it to limits table
00334   // if it was not already present:
00335   //
00336   if ( xid.severity < threshold        )  return false;
00337   if ( thisShouldBeIgnored(xid.module) 
00338         && (xid.severity < ELsevere) /* change log 2 */ )  
00339                                           return false;
00340   if ( ! limits.add( xid )              
00341         && (xid.severity < ELsevere) /* change log 2 */ )  
00342                                           return false;
00343 
00344   #ifdef ELoutputTRACE_LOG
00345     std::cerr << "    =:=:=: Limits table work done \n";
00346   #endif
00347 
00348   // Output the prologue:
00349   //
00350   preambleMode = true;
00351 
00352   if  ( !msg.is_verbatim()  ) {
00353     charsOnLine = 0;                                            // Change log 5
00354     emitToken( preamble );
00355     emitToken( xid.severity.getSymbol() );
00356     emitToken( " " );
00357     emitToken( xid.id );
00358     emitToken( msg.idOverflow() );
00359     emitToken( ": " );
00360   }
00361   
00362   #ifdef ELoutputTRACE_LOG
00363     std::cerr << "    =:=:=: Prologue done \n";
00364   #endif
00365   // Output serial number of message:
00366   //
00367   if  ( !msg.is_verbatim()  ) 
00368  {
00369     if ( wantSerial )  {
00370       std::ostringstream s;
00371       s << msg.serial();
00372       emitToken( "[serial #" + s.str() + ELstring("] ") );
00373     }
00374   }
00375   
00376 #ifdef OUTPUT_FORMATTED_ERROR_MESSAGES
00377   // Output each item in the message (before the epilogue):
00378   //
00379   if ( wantText )  {
00380     ELlist_string::const_iterator it;
00381     for ( it = msg.items().begin();  it != msg.items().end();  ++it )  {
00382     #ifdef ELoutputTRACE_LOG
00383       std::cerr << "      =:=:=: Item:  " << *it << '\n';
00384     #endif
00385       emitToken( *it );
00386     }
00387   }
00388 #endif
00389 
00390   // Provide further identification:
00391   //
00392   bool needAspace = true;
00393   if  ( !msg.is_verbatim()  ) 
00394  {
00395     if ( wantEpilogueSeparate )  {
00396       if ( xid.module.length() + xid.subroutine.length() > 0 )  {
00397         emitToken("\n");
00398         needAspace = false;
00399       }
00400       else if ( wantTimestamp && !wantTimeSeparate )  {
00401         emitToken("\n");
00402         needAspace = false;
00403       }
00404     }
00405     if ( wantModule && (xid.module.length() > 0) )  {
00406       if (needAspace) { emitToken(ELstring(" ")); needAspace = false; }
00407       emitToken( xid.module + ELstring(" ") );
00408     }
00409     if ( wantSubroutine && (xid.subroutine.length() > 0) )  {
00410       if (needAspace) { emitToken(ELstring(" ")); needAspace = false; }
00411       emitToken( xid.subroutine + "()" + ELstring(" ") );
00412     }
00413   }
00414   
00415   #ifdef ELoutputTRACE_LOG
00416     std::cerr << "    =:=:=: Module and Subroutine done \n";
00417   #endif
00418 
00419   // Provide time stamp:
00420   //
00421   if  ( !msg.is_verbatim() ) 
00422  {
00423     if ( wantTimestamp )  {
00424       if ( wantTimeSeparate )  {
00425         emitToken( ELstring("\n") );
00426         needAspace = false;
00427       }
00428       if (needAspace) { emitToken(ELstring(" ")); needAspace = false; }
00429       ELstring const& ftime = formatTime(msg.timestamp()); // Change log 7
00430       emitToken( ftime + ELstring(" ") );
00431     }
00432   }
00433   
00434   #ifdef ELoutputTRACE_LOG
00435     std::cerr << "    =:=:=: TimeStamp done \n";
00436   #endif
00437 
00438   // Provide the context information:
00439   //
00440   if  ( !msg.is_verbatim() ) 
00441  {
00442     if ( wantSomeContext ) {
00443       if (needAspace) { emitToken(ELstring(" ")); needAspace = false; }
00444       #ifdef ELoutputTRACE_LOG
00445         std::cerr << "    =:=:=:>> context supplier is at 0x"
00446                   << std::hex
00447                   << &ELadministrator::instance()->getContextSupplier() << '\n';
00448         std::cerr << "    =:=:=:>> context is --- "
00449                   << ELadministrator::instance()->getContextSupplier().context()
00450                   << '\n';
00451       #endif
00452       if ( wantFullContext )  {
00453         emitToken( ELadministrator::instance()->getContextSupplier().fullContext());
00454       #ifdef ELoutputTRACE_LOG
00455         std::cerr << "    =:=:=: fullContext done: \n";
00456       #endif
00457       } else  {
00458         emitToken( ELadministrator::instance()->getContextSupplier().context());
00459     #ifdef ELoutputTRACE_LOG
00460       std::cerr << "    =:=:=: Context done: \n";
00461     #endif
00462       }
00463     }
00464   }
00465   
00466   // Provide traceback information:
00467   //
00468 
00469   bool insertNewlineAfterHeader = ( msg.xid().severity != ELsuccess );
00470   // ELsuccess is what LogDebug issues
00471   
00472   if  ( !msg.is_verbatim() ) 
00473  {
00474     if ( msg.xid().severity >= traceThreshold )  {
00475       emitToken( ELstring("\n")
00476             + ELadministrator::instance()->getContextSupplier().traceRoutine()
00477           , insertNewlineAfterHeader );
00478     }
00479     else  {                                        //else statement added JV:1
00480       emitToken("", insertNewlineAfterHeader);
00481     }
00482   }
00483   #ifdef ELoutputTRACE_LOG
00484     std::cerr << "    =:=:=: Trace routine done: \n";
00485   #endif
00486 
00487 #ifndef OUTPUT_FORMATTED_ERROR_MESSAGES
00488   // Finally, output each item in the message:
00489   //
00490   preambleMode = false;
00491   if ( wantText )  {
00492     ELlist_string::const_iterator it;
00493     int item_count = 0;
00494     for ( it = msg.items().begin();  it != msg.items().end();  ++it )  {
00495     #ifdef ELoutputTRACE_LOG
00496       std::cerr << "      =:=:=: Item:  " << *it << '\n';
00497     #endif
00498       ++item_count;
00499       if  ( !msg.is_verbatim() ) {
00500         if ( !insertNewlineAfterHeader && (item_count == 3) ) {
00501           // in a LogDebug message, the first 3 items are FILE, :, and LINE
00502           emitToken( *it, true );
00503         } else {
00504           emitToken( *it );
00505         }
00506       } else {
00507         emitToken( *it );
00508       }
00509     }
00510   }
00511 #endif
00512 
00513   // And after the message, add a %MSG on its own line
00514   // Change log 4  6/11/07 mf
00515 
00516   if  ( !msg.is_verbatim() ) 
00517   {
00518     emitToken("\n%MSG");
00519   }
00520   
00521 
00522   // Done; message has been fully processed; separate, flush, and leave
00523   //
00524 
00525   (*os) << newline;
00526   flush(); 
00527 
00528 
00529   #ifdef ELoutputTRACE_LOG
00530     std::cerr << "  =:=:=: log(msg) done: \n";
00531   #endif
00532 
00533   return true;
00534 
00535 }  // log()
00536 
00537 
00538 // Remainder are from base class.
00539 
00540 // ----------------------------------------------------------------------
00541 // Output methods:
00542 // ----------------------------------------------------------------------
00543 
00544 void ELoutput::emitToken( const ELstring & s, bool nl )  {
00545 
00546   #ifdef ELoutput_EMIT_TRACE
00547     std::cerr << "[][][] in emit:  charsOnLine is " << charsOnLine << '\n';
00548     std::cerr << "[][][] in emit:  s.length() " << s.length() << '\n';
00549     std::cerr << "[][][] in emit:  lineLength is " << lineLength << '\n';
00550   #endif
00551 
00552   if (s.length() == 0)  {
00553     if ( nl )  {
00554       (*os) << newline << std::flush;
00555       charsOnLine = 0;
00556     }
00557     return;
00558   }
00559 
00560   char first = s[0];
00561   char second,
00562        last,
00563        last2;
00564   second = (s.length() < 2) ? '\0' : s[1];
00565   last = (s.length() < 2) ? '\0' : s[s.length()-1];
00566   last2 = (s.length() < 3) ? '\0' : s[s.length()-2];
00567          //checking -2 because the very last char is sometimes a ' ' inserted
00568          //by ErrorLog::operator<<
00569 
00570   if (preambleMode) {
00571                //Accounts for newline @ the beginning of the ELstring     JV:2
00572     if ( first == '\n'
00573     || (charsOnLine + static_cast<int>(s.length())) > lineLength )  {
00574       #ifdef ELoutput_EMIT_TRACE
00575         std::cerr << "[][][] in emit: about to << to *os \n";
00576       #endif
00577       #ifdef HEADERS_BROKEN_INTO_LINES_AND_INDENTED
00578       // Change log 3: Removed this code 6/11/07 mf
00579       (*os) << newline << indent;
00580       charsOnLine = indent.length();
00581       #else
00582       charsOnLine = 0;                                          // Change log 5   
00583       #endif
00584       if (second != ' ')  {
00585         (*os) << ' ';
00586         charsOnLine++;
00587       }
00588       if ( first == '\n' )  {
00589         (*os) << s.substr(1);
00590       }
00591       else  {
00592         (*os) << s;
00593       }
00594     }
00595     #ifdef ELoutput_EMIT_TRACE
00596       std::cerr << "[][][] in emit: about to << s to *os: " << s << " \n";
00597     #endif
00598     else  {
00599       (*os) << s;
00600     }
00601 
00602     if (last == '\n' || last2 == '\n')  {  //accounts for newline @ end    $$ JV:2
00603       (*os) << indent;                    //of the ELstring
00604       if (last != ' ')
00605         (*os) << ' ';
00606       charsOnLine = indent.length() + 1;
00607     }
00608 
00609     if ( nl )  { (*os) << newline << std::flush; charsOnLine = 0;           }
00610     else       {                                 charsOnLine += s.length(); }
00611 }
00612 
00613   if (!preambleMode) {
00614     (*os) << s;
00615   }
00616   
00617   #ifdef ELoutput_EMIT_TRACE
00618     std::cerr << "[][][] in emit: completed \n";
00619   #endif
00620 
00621 }  // emitToken()
00622 
00623 
00624 // ----------------------------------------------------------------------
00625 // Methods controlling message formatting:
00626 // ----------------------------------------------------------------------
00627 
00628 void ELoutput::includeTime()   { wantTimestamp = true;  }
00629 void ELoutput::suppressTime()  { wantTimestamp = false; }
00630 
00631 void ELoutput::includeModule()   { wantModule = true;  }
00632 void ELoutput::suppressModule()  { wantModule = false; }
00633 
00634 void ELoutput::includeSubroutine()   { wantSubroutine = true;  }
00635 void ELoutput::suppressSubroutine()  { wantSubroutine = false; }
00636 
00637 void ELoutput::includeText()   { wantText = true;  }
00638 void ELoutput::suppressText()  { wantText = false; }
00639 
00640 void ELoutput::includeContext()   { wantSomeContext = true;  }
00641 void ELoutput::suppressContext()  { wantSomeContext = false; }
00642 
00643 void ELoutput::suppressSerial()  { wantSerial = false; }
00644 void ELoutput::includeSerial()   { wantSerial = true;  }
00645 
00646 void ELoutput::useFullContext()  { wantFullContext = true;  }
00647 void ELoutput::useContext()      { wantFullContext = false; }
00648 
00649 void ELoutput::separateTime()  { wantTimeSeparate = true;  }
00650 void ELoutput::attachTime()    { wantTimeSeparate = false; }
00651 
00652 void ELoutput::separateEpilogue()  { wantEpilogueSeparate = true;  }
00653 void ELoutput::attachEpilogue()    { wantEpilogueSeparate = false; }
00654 
00655 
00656 // ----------------------------------------------------------------------
00657 // Summary output:
00658 // ----------------------------------------------------------------------
00659 
00660 void ELoutput::summarization(
00661   const ELstring & fullTitle
00662 , const ELstring & sumLines
00663 )  {
00664   const int titleMaxLength( 40 );
00665 
00666   // title:
00667   //
00668   ELstring title( fullTitle, 0, titleMaxLength );
00669   int q = (lineLength - title.length() - 2) / 2;
00670   ELstring line(q, '=');
00671   emitToken( "", true );
00672   emitToken( line );
00673   emitToken( " " );
00674   emitToken( title );
00675   emitToken( " " );
00676   emitToken( line, true );
00677 
00678   // body:
00679   //
00680   *os << sumLines;
00681 
00682   // finish:
00683   //
00684   emitToken( "", true );
00685   emitToken( ELstring(lineLength, '='), true );
00686 
00687 }  // summarization()
00688 
00689 
00690 // ----------------------------------------------------------------------
00691 // Changing ostream:
00692 // ----------------------------------------------------------------------
00693 
00694 void ELoutput::changeFile (std::ostream & os_) {
00695   os.reset(&os_, do_nothing_deleter());
00696   emitToken( "\n=======================================================", true );
00697   emitToken( "\nError Log changed to this stream\n" );
00698   ELstring const& ftime = formatTime(time(0)); // Change log 7
00699   emitToken( ftime, true );
00700   emitToken( "\n=======================================================\n", true );
00701 }
00702 
00703 void ELoutput::changeFile (const ELstring & filename) {
00704   os.reset(new std::ofstream( filename.c_str(), std::ios/*_base*/::app), close_and_delete());
00705   emitToken( "\n=======================================================", true );
00706   emitToken( "\nError Log changed to this file\n" );
00707   ELstring const& ftime = formatTime(time(0)); // Change log 7
00708   emitToken( ftime, true );
00709   emitToken( "\n=======================================================\n", true );
00710 }
00711 
00712 void ELoutput::flush()  {
00713   os->flush();
00714 }
00715 
00716 
00717 // ----------------------------------------------------------------------
00718 
00719 
00720 } // end of namespace service  
00721 } // end of namespace edm