CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
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  ELdestControl attach( const ELdestination & sink );
97  ELdestControl attach( const ELdestination & sink, const ELstring & name );
98 
99  // --- handle severity information:
100  //
102  int severityCount( const ELseverityLevel & sev ) const;
103  int severityCount( const ELseverityLevel & from,
104  const ELseverityLevel & to ) const;
105  void resetSeverityCount( const ELseverityLevel & sev );
106  void resetSeverityCount( const ELseverityLevel & from,
107  const ELseverityLevel & to );
108  void resetSeverityCount(); // reset all
109 
110  // --- apply the following actions to all attached destinations:
111  //
112  void setThresholds( const ELseverityLevel & sev );
113  void setLimits ( const ELstring & id, int limit );
114  void setLimits ( const ELseverityLevel & sev, int limit );
115  void setIntervals ( const ELstring & id, int interval );
116  void setIntervals ( const ELseverityLevel & sev, int interval );
117  void setTimespans ( const ELstring & id, int seconds );
118  void setTimespans ( const ELseverityLevel & sev, int seconds );
119  void wipe();
120  void finish();
121 
122 protected:
123  // --- member data accessors:
124  //
125  const ELseverityLevel & abortThreshold() const;
126  const ELseverityLevel & exitThreshold() const;
127  std::list<std::shared_ptr<ELdestination> > & sinks();
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<std::shared_ptr<ELdestination> > sinks_;
143 
144  std::map < ELstring, 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)
tuple interval
Definition: MergeJob_cfg.py:20
void setIntervals(const ELstring &id, int interval)
void setLimits(const ELstring &id, int limit)
std::map< ELstring, std::shared_ptr< ELdestination > > attachedDestinations_
void setTimespans(const ELstring &id, int seconds)
int severityCounts(int lev) const
int severityCount(const ELseverityLevel &sev) const
std::list< std::shared_ptr< ELdestination > > sinks_
std::list< std::shared_ptr< ELdestination > > & sinks()
const ELseverityLevel & exitThreshold() const
ELdestControl attach(const ELdestination &sink)
std::string ELstring
Definition: ELstring.h:26