CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/FWCore/MessageService/src/ELcollected.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 //
00003 // ELcollected.cc
00004 //
00005 // History:
00006 //   07-Jun-2000  WEB  Reflect consolidation of ELdestination/X and of
00007 //     ELoutput/X; consolidate ELcollected/X
00008 //   15-Sep-2000  MF   Corrected bug:  copy constructor needs to set sender
00009 //                      based on a clone() of *sender, not a bit copy, since
00010 //                      the whole reasoning was to protect against the user's
00011 //                      objects going out of scope.
00012 //   4-Apr-2001   MF    Loginc to ignore ore respond to modules, using base
00013 //                      method thisShouldBeIgnored().
00014 //
00015 // ----------------------------------------------------------------------
00016 
00017 #include "FWCore/MessageService/interface/ELcollected.h"
00018 #include "FWCore/MessageService/interface/ELdestination.h"
00019 #include "FWCore/MessageService/interface/ELadministrator.h"
00020 #include "FWCore/MessageService/interface/ELcontextSupplier.h"
00021 
00022 #include <sstream>
00023 
00024 // Possible Traces:
00025 //#define ELcollectedCONSTRUCTOR_TRACE
00026 //#define ELcollectedTRACE_LOG
00027 //#define ELcollected_EMIT_TRACE
00028 
00029 namespace edm {
00030 namespace service {
00031 
00032 
00033 // ----------------------------------------------------------------------
00034 // Constructors:
00035 // ----------------------------------------------------------------------
00036 
00037 ELcollected::ELcollected( const ELsender & snd )
00038 : ELoutput()
00039 , sender  ( snd.clone() )
00040 {
00041 
00042   #ifdef ELcollectedCONSTRUCTOR_TRACE
00043     std::cout << "Constructor for ELcollected(ELsender)\n";
00044   #endif
00045 
00046   // Unlike ELoutput, we do not emit Error Log established message.
00047 
00048 }  // ELcollected()
00049 
00050 
00051 ELcollected::ELcollected( const ELcollected & orig )
00052 : ELoutput( orig        )
00053 , sender  ( orig.sender->clone() )              // $$ mf 9/15/00
00054 {
00055 
00056   #ifdef ELcollectedCONSTRUCTOR_TRACE
00057     std::cout << "Copy constructor for ELcollected\n";
00058   #endif
00059 
00060   ignoreMostModules    = orig.ignoreMostModules;
00061   respondToThese       = orig.respondToThese;
00062   respondToMostModules = orig.respondToMostModules;
00063   ignoreThese          = orig.ignoreThese;
00064 
00065 }  // ELcollected()
00066 
00067 
00068 ELcollected::~ELcollected()  {
00069 
00070   #ifdef ELcollectedCONSTRUCTOR_TRACE
00071     std::cout << "Destructor for ELcollected)\n";
00072   #endif
00073 }  // ~ELcollected()
00074 
00075 
00076 
00077 // ----------------------------------------------------------------------
00078 // Methods invoked by the ELadministrator:
00079 // ----------------------------------------------------------------------
00080 
00081 ELcollected *
00082 ELcollected::clone() const  {
00083 
00084   return  new ELcollected( *this );
00085 
00086 } // clone()
00087 
00088 
00089 // Remainder are from base class.
00090 
00091 // =======
00092 // intoBuf
00093 // =======
00094 
00095 void ELcollected::intoBuf( const ELstring & s )  {
00096 
00097   buf += s;
00098   buf += '\0';
00099 
00100 } // intoBuf();
00101 
00102 
00103 // ========
00104 // emitXid
00105 // ========
00106 
00107 void ELcollected::emitXid( const ELextendedID & xid )  {
00108 
00109   buf = "";
00110 
00111   intoBuf ( xid.process    );
00112   intoBuf ( xid.module     );
00113   intoBuf ( xid.subroutine );
00114   intoBuf ( xid.id         );
00115   std::ostringstream ost;
00116   ost << xid.severity.getLevel();
00117   intoBuf ( ost.str() );
00118 
00119 } // emitXid
00120 
00121 
00122 // =====
00123 // emit
00124 // =====
00125 
00126 void ELcollected::emitToken( const ELstring & s, bool nl )  {
00127 
00128   #ifdef ELcollected_EMIT_TRACE
00129     std::cout << "[][][] in emit:  s.length() " << s.length() << "\n";
00130   #endif
00131 
00132   // A forced newline is something that needs to be transmitted.
00133   // We shall insert it as its own item.
00134 
00135   if (s.length() == 0)  {
00136     if ( nl )  {
00137       intoBuf( newline );
00138       charsOnLine = 0;
00139     }
00140     return;
00141   }
00142 
00143   // Setting up for indentation if you start with a nweline, or if the length
00144   // exceeds column 80, is not done here, it is done on the server.
00145 
00146   #ifdef ELcollected_EMIT_TRACE
00147     std::cout << "[][][] in emit: about to << s to buf: " << s << " \n";
00148   #endif
00149 
00150   // Place the item into the buffer
00151 
00152   intoBuf (s);
00153 
00154   // Accounting for trailing \n is done at the server.
00155 
00156   // A forced trailing newline is something that needs to be transmitted.
00157   // We shall insert it as its own item.
00158 
00159   if ( nl )  {
00160     intoBuf (newline);
00161   }
00162 
00163   #ifdef ELcollected_EMIT_TRACE
00164     std::cout << "[][][] in emit: completed \n";
00165   #endif
00166 
00167 }  // emitToken()
00168 
00169 
00170 
00171 // ====
00172 // log
00173 // ====
00174 
00175 bool ELcollected::log( const edm::ErrorObj & msg )  {
00176 
00177   #ifdef ELcollectedTRACE_LOG
00178     std::cout << "    =:=:=: Log to an ELcollected \n";
00179   #endif
00180 
00181   xid = msg.xid();      // Save the xid.
00182 
00183   // See if this message is to be acted upon, and add it to limits table
00184   // if it was not already present:
00185   //
00186   if ( msg.xid().severity < threshold  )  return false;
00187   if ( thisShouldBeIgnored(xid.module) )  return false;
00188   if ( ! limits.add( msg.xid() )      )   return false;
00189 
00190   #ifdef ELcollectedTRACE_LOG
00191     std::cout << "    =:=:=: Limits table work done \n";
00192   #endif
00193 
00194   // start the buffer with the xid
00195 
00196   emitXid (xid);
00197 
00198   //
00199 
00200   #ifdef ELcollectedTRACE_LOG
00201     std::cout << "    =:=:=: xid emitted \n";
00202   #endif
00203 
00204   // Provide the context information.  The server side will use this to prime
00205   // its special context supplier.  We will send over all three types of
00206   // context, even though probably only 1 or 2 will be needed.
00207 
00208   emitToken( ELadministrator::instance()->
00209                         getContextSupplier().summaryContext());
00210   emitToken( ELadministrator::instance()->
00211                         getContextSupplier().context());
00212   emitToken( ELadministrator::instance()->
00213                         getContextSupplier().fullContext());
00214 
00215   #ifdef ELcollectedTRACE_LOG
00216     std::cout << "    =:=:=: Context done: \n";
00217   #endif
00218 
00219   // No prologue separate from what the server will issue.
00220 
00221   // No serial number of message separate from what the server will issue.
00222 
00223   // collected each item in the message:
00224   //
00225   if ( wantText )  {
00226     ELlist_string::const_iterator it;
00227     for ( it = msg.items().begin();  it != msg.items().end();  ++it )  {
00228   #ifdef ELcollectedTRACE_LOG
00229     std::cout << "      =:=:=: Item:  " << *it <<"\n";
00230   #endif
00231       emitToken( *it );
00232     }
00233   }
00234 
00235   // DO NOT Provide further identification such as module and subroutine;
00236   // the server side will provide that using the xid you have sent it, if
00237   // the server side user wants it.
00238 
00239   // DO NOT provide time stamp; it would duplicate server's stamp!
00240 
00241   // Provide traceback information:
00242   //
00243   if ( msg.xid().severity >= traceThreshold )  {
00244     emitToken( ELstring("\n")
00245           + ELadministrator::instance()->getContextSupplier().traceRoutine()
00246         , true );
00247   }
00248   else  {                                        //else statement added JV:1
00249     emitToken( "", true );
00250   }
00251   #ifdef ELcollectedTRACE_LOG
00252     std::cout << "    =:=:=: Trace routine done: \n";
00253   #endif
00254 
00255   // Message has been fully processed through emit; now put in an extra
00256   // zero, and send out the buffer.
00257   //
00258 
00259   buf += char(0);
00260   int nbuf = buf.length();
00261 
00262   sender->send ( nbuf, buf.data() );
00263 
00264   #ifdef ELcollectedTRACE_LOG
00265     std::cout << "  =:=:=: log(msg) done: \n";
00266   #endif
00267 
00268   return true;
00269 
00270 }  // log()
00271 
00272 
00273 // ----------------------------------------------------------------------
00274 
00275 
00276 } // end of namespace service  
00277 } // end of namespace edm  
00278