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