CMS 3D CMS Logo

ELadministrator.h
Go to the documentation of this file.
1 #ifndef MessageService_ELadministrator_h
2 #define MessageService_ELadministrator_h
3 
4 // ----------------------------------------------------------------------
5 //
6 // ELadminstrator.h provides the singleton class that the framework uses to
7 // control logger behavior including attaching destinations.
8 // Includes the methods used by ErrorLog to evoke the logging
9 // behavior in the destinations owned by the ELadminstrator.
10 //
11 // ----------------------------------------------------------------------
12 //
13 // ELadministrator The singleton logger class. One does not instantiate
14 // an ELadministrator. Instead, do
15 // ELadministrator * logger = ELadministrator::instance();
16 // to get a pointer to the (unique) ELadministrator.
17 //
18 // Only the framework should use ELadministrator directly.
19 // Physicist users get at it indirectly through using an ErrorLog
20 // set up in their Module class.
21 //
22 // ELadminDestroyer A class whose sole purpose is the destruction of the
23 // ELadministrator when the program is over. Right now,
24 // we do not have anything that needs to be done when the
25 // ELadministrator (and thus the error logger) goes away;
26 // but since by not deleting the copies of ELdestination's
27 // that were attached we would be left with an apparent
28 // memory leak, we include a protected destructor which will
29 // clean up. ELadminDestroyer provides the only way for
30 // this destructor to be called.
31 //
32 // ----------------------------------------------------------------------
33 //
34 // 7/2/98 mf Created file.
35 // 2/29/00 mf Added method swapContextSupplier for ELrecv to use.
36 // 4/5/00 mf Added method swapProcess for same reason: ELrecv wants to
37 // be able to mock up the process and reset it afterward.
38 // 6/6/00 web Consolidate ELadministrator/X; adapt to consolidated
39 // ELcout/X.
40 // 6/14/00 web Declare classes before granting friendship.
41 // 6/4/01 mf Grant friedship to ELtsErrorLog
42 // 3/6/02 mf Items for recovering handles to attached destinations:
43 // the attachedDestinations map,
44 // an additional signature for attach(),
45 // and getELdestControl() method
46 // 3/17/04 mf exitThreshold and setExitThreshold
47 // 1/10/06 mf finish
48 //
49 // ----------------------------------------------------------------------
50 
57 
58 #include <memory>
59 
60 namespace edm {
61  namespace service {
62 
63  // ----------------------------------------------------------------------
64  // Prerequisite classes:
65  // ----------------------------------------------------------------------
66 
67  class ELdestination;
68  class ELcout;
69  class MessageLoggerScribe;
70 
71  // ----------------------------------------------------------------------
72  // ELadministrator:
73  // ----------------------------------------------------------------------
74 
75  class ELadministrator { // *** Destructable Singleton Pattern ***
76 
77  friend class MessageLoggerScribe; // proper ELadministrator cleanup
78  friend class ThreadSafeLogMessageLoggerScribe; // proper ELadministrator cleanup
79  friend class ELcout; // ELcout behavior
80 
81  // *** Error Logger Functionality ***
82 
83  public:
85 
86  //Replaces ErrorLog which is no longer needed
87  void log(edm::ErrorObj& msg);
88 
89  // --- furnish/recall destinations:
90  //
91  std::shared_ptr<ELdestination> attach(std::shared_ptr<ELdestination> sink);
92 
93  // --- handle severity information:
94  //
96  int severityCount(const ELseverityLevel& sev) const;
97  int severityCount(const ELseverityLevel& from, const ELseverityLevel& to) const;
98  void resetSeverityCount(const ELseverityLevel& sev);
99  void resetSeverityCount(const ELseverityLevel& from, const ELseverityLevel& to);
100  void resetSeverityCount(); // reset all
101 
102  // --- apply the following actions to all attached destinations:
103  //
104  void setThresholds(const ELseverityLevel& sev);
105  void setLimits(const ELstring& id, int limit);
106  void setLimits(const ELseverityLevel& sev, int limit);
107  void setIntervals(const ELstring& id, int interval);
108  void setIntervals(const ELseverityLevel& sev, int interval);
109  void setTimespans(const ELstring& id, int seconds);
110  void setTimespans(const ELseverityLevel& sev, int seconds);
111  void wipe();
112  void finish();
113 
114  protected:
115  // --- member data accessors:
116  //
117  const ELseverityLevel& abortThreshold() const;
118  const ELseverityLevel& exitThreshold() const;
119  const ELseverityLevel& highSeverity() const;
120  int severityCounts(int lev) const;
121 
122  protected:
123  // --- traditional birth/death, but disallowed to users:
124  //
125  ELadministrator();
126 
127  private:
128  // --- traditional member data:
129  //
130  std::list<edm::propagate_const<std::shared_ptr<ELdestination>>> sinks_;
133 
134  std::map<ELstring, edm::propagate_const<std::shared_ptr<ELdestination>>> attachedDestinations_;
135 
136  }; // ELadministrator
137 
138  // ----------------------------------------------------------------------
139 
140  } // end of namespace service
141 } // end of namespace edm
142 
143 #endif // MessageService_ELadministrator_h
const ELseverityLevel & highSeverity() const
void log(edm::ErrorObj &msg)
const ELseverityLevel & abortThreshold() const
int severityCounts_[ELseverityLevel::nLevels]
std::shared_ptr< ELdestination > attach(std::shared_ptr< ELdestination > sink)
double seconds()
void setThresholds(const ELseverityLevel &sev)
void setIntervals(const ELstring &id, int interval)
void setLimits(const ELstring &id, int limit)
void setTimespans(const ELstring &id, int seconds)
std::list< edm::propagate_const< std::shared_ptr< ELdestination > > > sinks_
tuple msg
Definition: mps_check.py:279
int severityCounts(int lev) const
int severityCount(const ELseverityLevel &sev) const
HLT enums.
const ELseverityLevel & exitThreshold() const
std::string ELstring
Definition: ELstring.h:21
std::map< ELstring, edm::propagate_const< std::shared_ptr< ELdestination > > > attachedDestinations_