Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:41

0001 #ifndef MessageService_ELadministrator_h
0002 #define MessageService_ELadministrator_h
0003 
0004 // ----------------------------------------------------------------------
0005 //
0006 // ELadminstrator.h  provides the singleton class that the framework uses to
0007 //           control logger behavior including attaching destinations.
0008 //      Includes the methods used by ErrorLog to evoke the logging
0009 //      behavior in the destinations owned by the ELadminstrator.
0010 //
0011 // ----------------------------------------------------------------------
0012 //
0013 // ELadministrator   The singleton logger class.  One does not instantiate
0014 //           an ELadministrator.  Instead, do
0015 //          ELadministrator * logger = ELadministrator::instance();
0016 //           to get a pointer to the (unique) ELadministrator.
0017 //
0018 //  Only the framework should use ELadministrator directly.
0019 //  Physicist users get at it indirectly through using an ErrorLog
0020 //  set up in their Module class.
0021 //
0022 // ELadminDestroyer  A class whose sole purpose is the destruction of the
0023 //                   ELadministrator when the program is over.  Right now,
0024 //                   we do not have anything that needs to be done when the
0025 //                   ELadministrator (and thus the error logger) goes away;
0026 //                   but since by not deleting the copies of ELdestination's
0027 //                   that were attached we would be left with an apparent
0028 //                   memory leak, we include a protected destructor which will
0029 //                   clean up.  ELadminDestroyer provides the only way for
0030 //                   this destructor to be called.
0031 //
0032 // ----------------------------------------------------------------------
0033 //
0034 // 7/2/98 mf    Created file.
0035 // 2/29/00 mf   Added method swapContextSupplier for ELrecv to use.
0036 // 4/5/00 mf    Added method swapProcess for same reason:  ELrecv wants to
0037 //      be able to mock up the process and reset it afterward.
0038 // 6/6/00 web   Consolidate ELadministrator/X; adapt to consolidated
0039 //      ELcout/X.
0040 // 6/14/00 web  Declare classes before granting friendship.
0041 // 6/4/01  mf   Grant friedship to ELtsErrorLog
0042 // 3/6/02  mf   Items for recovering handles to attached destinations:
0043 //      the attachedDestinations map,
0044 //      an additional signature for attach(),
0045 //      and getELdestControl() method
0046 // 3/17/04 mf   exitThreshold and setExitThreshold
0047 // 1/10/06 mf   finish
0048 //
0049 // ----------------------------------------------------------------------
0050 
0051 #include "FWCore/MessageLogger/interface/ELlist.h"
0052 #include "FWCore/MessageLogger/interface/ELseverityLevel.h"
0053 #include "FWCore/MessageLogger/interface/ErrorObj.h"
0054 #include "FWCore/MessageService/src/ELdestination.h"
0055 #include "FWCore/Utilities/interface/propagate_const.h"
0056 
0057 #include <memory>
0058 
0059 namespace edm {
0060   namespace service {
0061 
0062     // ----------------------------------------------------------------------
0063     // ELadministrator:
0064     // ----------------------------------------------------------------------
0065 
0066     class ELadministrator {
0067     public:
0068       ELadministrator();
0069       ~ELadministrator();
0070 
0071       //Replaces ErrorLog which is no longer needed
0072       void log(edm::ErrorObj& msg);
0073 
0074       // ---  furnish/recall destinations:
0075       //
0076       std::shared_ptr<ELdestination> attach(std::shared_ptr<ELdestination> sink);
0077 
0078       // ---  handle severity information:
0079       //
0080       messagelogger::ELseverityLevel checkSeverity();
0081       int severityCount(const messagelogger::ELseverityLevel& sev) const;
0082       int severityCount(const messagelogger::ELseverityLevel& from, const messagelogger::ELseverityLevel& to) const;
0083       void resetSeverityCount(const messagelogger::ELseverityLevel& sev);
0084       void resetSeverityCount(const messagelogger::ELseverityLevel& from, const messagelogger::ELseverityLevel& to);
0085       void resetSeverityCount();  // reset all
0086 
0087       // ---  apply the following actions to all attached destinations:
0088       //
0089       void setThresholds(const messagelogger::ELseverityLevel& sev);
0090       void setLimits(const std::string& id, int limit);
0091       void setLimits(const messagelogger::ELseverityLevel& sev, int limit);
0092       void setIntervals(const std::string& id, int interval);
0093       void setIntervals(const messagelogger::ELseverityLevel& sev, int interval);
0094       void setTimespans(const std::string& id, int seconds);
0095       void setTimespans(const messagelogger::ELseverityLevel& sev, int seconds);
0096       void wipe();
0097       void finish();
0098 
0099     protected:
0100       // ---  member data accessors:
0101       //
0102       const messagelogger::ELseverityLevel& abortThreshold() const;
0103       const messagelogger::ELseverityLevel& exitThreshold() const;
0104       const messagelogger::ELseverityLevel& highSeverity() const;
0105       int severityCounts(int lev) const;
0106 
0107     private:
0108       // ---  traditional member data:
0109       //
0110       std::list<edm::propagate_const<std::shared_ptr<ELdestination>>> sinks_;
0111       messagelogger::ELseverityLevel highSeverity_;
0112       int severityCounts_[messagelogger::ELseverityLevel::nLevels];
0113 
0114       std::map<std::string, edm::propagate_const<std::shared_ptr<ELdestination>>> attachedDestinations_;
0115 
0116     };  // ELadministrator
0117 
0118     // ----------------------------------------------------------------------
0119 
0120   }  // end of namespace service
0121 }  // end of namespace edm
0122 
0123 #endif  // MessageService_ELadministrator_h