CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FWCore/MessageLogger/src/MessageSender.cc

Go to the documentation of this file.
00001 #include "FWCore/MessageLogger/interface/MessageSender.h"
00002 #include "FWCore/MessageLogger/interface/MessageLoggerQ.h"
00003 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00004 
00005 #define TRACE_DROP
00006 #ifdef TRACE_DROP
00007 #include <iostream>
00008 #endif
00009 
00010 // Change log
00011 //
00012 //  1  mf 8/25/08       keeping the error summary information for
00013 //                      LoggedErrorsSummary()
00014 //                      
00015 // 2  mf 11/2/10        Use new moduleContext method of MessageDrop:
00016 //                      see MessageServer/src/MessageLogger.cc change 17.
00017 //                      
00018 
00019 
00020 using namespace edm;
00021 
00022 bool MessageSender::errorSummaryIsBeingKept = false;            // change log 1
00023 bool MessageSender::freshError              = false;
00024 std::map<ErrorSummaryMapKey, unsigned int> MessageSender::errorSummaryMap; 
00025 
00026 MessageSender::MessageSender( ELseverityLevel const & sev, 
00027                               ELstring const & id,
00028                               bool verbatim )
00029 : errorobj_p( new ErrorObj(sev,id,verbatim) )
00030 {
00031   //std::cout << "MessageSender ctor; new ErrorObj at: " << errorobj_p << '\n';
00032 }
00033 
00034 MessageSender::MessageSender( ELseverityLevel const & sev, 
00035                               ELstring const & id )
00036 : errorobj_p( new ErrorObj(sev,id,false) )
00037 {
00038   //std::cout << "MessageSender ctor; new ErrorObj at: " << errorobj_p << '\n';
00039 }
00040 
00041 
00042 // This destructor must not be permitted to throw. A
00043 // boost::thread_resoruce_error is thrown at static destruction time,
00044 // if the MessageLogger library is loaded -- even if it is not used.
00045 MessageSender::~MessageSender()
00046 {
00047   try 
00048     {
00049       //std::cout << "MessageSender dtor; ErrorObj at: " << errorobj_p << '\n';
00050 
00051       // surrender ownership of our ErrorObj, transferring ownership
00052       // (via the intermediate MessageLoggerQ) to the MessageLoggerScribe
00053       // that will (a) route the message text to its destination(s)
00054       // and will then (b) dispose of the ErrorObj
00055       
00056       MessageDrop * drop = MessageDrop::instance();
00057       if (drop) {
00058         errorobj_p->setModule(drop->moduleContext());           // change log 
00059         errorobj_p->setContext(drop->runEvent);
00060       } 
00061 #ifdef TRACE_DROP
00062       if (!drop) std::cerr << "MessageSender::~MessageSender() - Null drop pointer \n";
00063 #endif
00064                                                                 // change log 1
00065       if ( errorSummaryIsBeingKept && 
00066            errorobj_p->xid().severity >= ELwarning ) 
00067       {                         
00068         ELextendedID const & xid = errorobj_p->xid();
00069         ErrorSummaryMapKey key (xid.id, xid.module, xid.severity);
00070         ErrorSummaryMapIterator i = errorSummaryMap.find(key);
00071         if (i != errorSummaryMap.end()) {
00072           ++(i->second);  // same as ++errorSummaryMap[key]
00073         } else {
00074           errorSummaryMap[key] = 1;
00075         }
00076         freshError = true;
00077       }
00078       
00079       MessageLoggerQ::MLqLOG(errorobj_p);
00080     }
00081   catch ( ... )
00082     {
00083       // nothing to do
00084       
00085       // for test that removal of thread-involved static works, 
00086       // simply throw here, then run in trivial_main in totalview
00087       // and Next or Step so that the exception would be detected.
00088       // That test has been done 12/14/07.
00089     }
00090 }