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 
53 
59 
60 #include <memory>
61 
62 namespace edm {
63 namespace service {
64 
65 
66 // ----------------------------------------------------------------------
67 // Prerequisite classes:
68 // ----------------------------------------------------------------------
69 
70 class ELdestination;
71 class ELcout;
72 class MessageLoggerScribe;
73 
74 
75 // ----------------------------------------------------------------------
76 // ELadministrator:
77 // ----------------------------------------------------------------------
78 
79 class ELadministrator { // *** Destructable Singleton Pattern ***
80 
81  friend class MessageLoggerScribe; // proper ELadministrator cleanup
82  friend class ThreadSafeLogMessageLoggerScribe; // proper ELadministrator cleanup
83  friend class ELcout; // ELcout behavior
84 
85 // *** Error Logger Functionality ***
86 
87 public:
88 
90 
91 
92  //Replaces ErrorLog which is no longer needed
93  void log(edm::ErrorObj & msg);
94 
95  // --- furnish/recall destinations:
96  //
97  ELdestControl attach( const ELdestination & sink );
98  ELdestControl attach( const ELdestination & sink, const ELstring & name );
99 
100  // --- handle severity information:
101  //
103  int severityCount( const ELseverityLevel & sev ) const;
104  int severityCount( const ELseverityLevel & from,
105  const ELseverityLevel & to ) const;
106  void resetSeverityCount( const ELseverityLevel & sev );
107  void resetSeverityCount( const ELseverityLevel & from,
108  const ELseverityLevel & to );
109  void resetSeverityCount(); // reset all
110 
111  // --- apply the following actions to all attached destinations:
112  //
113  void setThresholds( const ELseverityLevel & sev );
114  void setLimits ( const ELstring & id, int limit );
115  void setLimits ( const ELseverityLevel & sev, int limit );
116  void setIntervals ( const ELstring & id, int interval );
117  void setIntervals ( const ELseverityLevel & sev, int interval );
118  void setTimespans ( const ELstring & id, int seconds );
119  void setTimespans ( const ELseverityLevel & sev, int seconds );
120  void wipe();
121  void finish();
122 
123 protected:
124  // --- member data accessors:
125  //
126  const ELseverityLevel & abortThreshold() const;
127  const ELseverityLevel & exitThreshold() const;
128  const ELseverityLevel & highSeverity() const;
129  int severityCounts( int lev ) const;
130 
131 protected:
132  // --- traditional birth/death, but disallowed to users:
133  //
134  ELadministrator();
135 
136 private:
137 
138  // --- traditional member data:
139  //
140  std::list<edm::propagate_const<std::shared_ptr<ELdestination>>> sinks_;
143 
144  std::map<ELstring, edm::propagate_const<std::shared_ptr<ELdestination>>> attachedDestinations_;
145 
146 }; // ELadministrator
147 
148 
149 // ----------------------------------------------------------------------
150 
151 
152 } // end of namespace service
153 } // end of namespace edm
154 
155 
156 #endif // MessageService_ELadministrator_h
const ELseverityLevel & highSeverity() const
void log(edm::ErrorObj &msg)
const ELseverityLevel & abortThreshold() const
int severityCounts_[ELseverityLevel::nLevels]
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
ELdestControl attach(const ELdestination &sink)
std::string ELstring
Definition: ELstring.h:26
std::map< ELstring, edm::propagate_const< std::shared_ptr< ELdestination > > > attachedDestinations_