CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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, bool suppressed )
00029 : errorobj_p( suppressed ? 0 : new ErrorObj(sev,id,verbatim), ErrorObjDeleter())
00030 {
00031   //std::cout << "MessageSender ctor; new ErrorObj at: " << errorobj_p << '\n';
00032 }
00033 
00034 
00035 // This destructor must not be permitted to throw. A
00036 // boost::thread_resoruce_error is thrown at static destruction time,
00037 // if the MessageLogger library is loaded -- even if it is not used.
00038 void MessageSender::ErrorObjDeleter::operator()(ErrorObj * errorObjPtr) {
00039   if (errorObjPtr == 0) {
00040     return;
00041   }
00042   try 
00043     {
00044       //std::cout << "MessageSender dtor; ErrorObj at: " << errorobj_p << '\n';
00045 
00046       // surrender ownership of our ErrorObj, transferring ownership
00047       // (via the intermediate MessageLoggerQ) to the MessageLoggerScribe
00048       // that will (a) route the message text to its destination(s)
00049       // and will then (b) dispose of the ErrorObj
00050       
00051       MessageDrop * drop = MessageDrop::instance();
00052       if (drop) {
00053         errorObjPtr->setModule(drop->moduleContext());          // change log 
00054         errorObjPtr->setContext(drop->runEvent);
00055       } 
00056 #ifdef TRACE_DROP
00057       if (!drop) std::cerr << "MessageSender::~MessageSender() - Null drop pointer \n";
00058 #endif
00059                                                                 // change log 1
00060       if ( errorSummaryIsBeingKept && 
00061            errorObjPtr->xid().severity >= ELwarning ) 
00062       {                         
00063         ELextendedID const & xid = errorObjPtr->xid();
00064         ErrorSummaryMapKey key (xid.id, xid.module, xid.severity);
00065         ErrorSummaryMapIterator i = errorSummaryMap.find(key);
00066         if (i != errorSummaryMap.end()) {
00067           ++(i->second);  // same as ++errorSummaryMap[key]
00068         } else {
00069           errorSummaryMap[key] = 1;
00070         }
00071         freshError = true;
00072       }
00073       
00074       MessageLoggerQ::MLqLOG(errorObjPtr);
00075     }
00076   catch ( ... )
00077     {
00078       // nothing to do
00079       
00080       // for test that removal of thread-involved static works, 
00081       // simply throw here, then run in trivial_main in totalview
00082       // and Next or Step so that the exception would be detected.
00083       // That test has been done 12/14/07.
00084     }
00085 }
00086 MessageSender::~MessageSender()
00087 {
00088 }