CMS 3D CMS Logo

ELdestination.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 //
3 // ELdestination.cc
4 //
5 // History:
6 //
7 // 7/5/98 mf Created
8 // 6/16/99 jvr Allow suppress/include options on destinations
9 // 7/2/99 jvr Added separate/attachTime, Epilogue, and Serial
10 // options
11 // 6/7/00 web Consolidate ELdestination/X; add filterModule()
12 // 8/22/00 web Fix omitted .getSymbol() call
13 // 10/4/00 mf excludeModule()
14 // 1/15/01 mf setLineLength()
15 // 2/13/01 mf fix written by pc to accomodate NT problem with
16 // static init { $001$ }. Corresponding fix is in
17 // .h file.
18 // 3/13/01 mf statisticsMap()
19 // 4/05/01 mf multi-module filtering
20 // 4/12/01 mf repair multi-module filtering
21 // 6/23/03 mf changeFile(), flush()
22 // 1/10/06 mf finish()
23 // 6/19/08 mf summaryForJobReport()
24 //
25 // ----------------------------------------------------------------------
26 
27 
28 #include <iostream>
29 #include <fstream>
30 
32 
33 // Possible Traces:
34 // #define ELdestinationCONSTRUCTOR_TRACE
35 
36 namespace edm {
37 namespace service {
38  // Fix $001 2/13/01 mf
39 #ifdef DEFECT_NO_STATIC_CONST_INIT
40  const int ELdestination::defaultLineLength = 80;
41 #endif
42 
45 , traceThreshold( ELhighestSeverity )
46 , limits ( )
47 , preamble ( "%MSG" )
48 , newline ( "\n" )
49 , indent ( " " )
50 , lineLength ( defaultLineLength )
51 , ignoreMostModules (false)
52 , respondToThese()
53 , respondToMostModules (false)
54 , ignoreThese()
55 {
56 
57  #ifdef ELdestinationCONSTRUCTOR_TRACE
58  std::cerr << "Constructor for ELdestination\n";
59  #endif
60 
61 } // ELdestination()
62 
63 
65 
66  #ifdef ELdestinationCONSTRUCTOR_TRACE
67  std::cerr << "Destructor for ELdestination\n";
68  #endif
69 
70 } // ~ELdestination()
71 
72 
73 // ----------------------------------------------------------------------
74 // Methods invoked by the ELadministrator:
75 // ----------------------------------------------------------------------
76 
77 bool ELdestination::log( const edm::ErrorObj &) { return false; }
78 
79 
80 // ----------------------------------------------------------------------
81 // Methods invoked through the ELdestControl handle:
82 // ----------------------------------------------------------------------
83 
84 // Each of these must be overridden by any destination for which they make
85 // sense. In this base class, where they are all no-ops, the methods which
86 // generate data to a destination, stream or stream will warn at that place,
87 // and all the no-op methods will issue an ELwarning2 at their own destination.
88 
89 
90 static const ELstring hereMsg = "available via this destination";
91 static const ELstring noosMsg = "No ostream";
92 static const ELstring notELoutputMsg = "This destination is not an ELoutput";
93 
94 // ----------------------------------------------------------------------
95 // Behavior control methods invoked by the framework
96 // ----------------------------------------------------------------------
97 
99  threshold = sv;
100 }
101 
102 
104  traceThreshold = sv;
105 }
106 
107 
108 void ELdestination::setLimit( const ELstring & s, int n ) {
109  limits.setLimit( s, n );
110 }
111 
112 
114 ( const ELseverityLevel & sv, int interval ) {
115  limits.setInterval( sv, interval );
116 }
117 
118 void ELdestination::setInterval( const ELstring & s, int interval ) {
119  limits.setInterval( s, interval );
120 }
121 
122 
123 void ELdestination::setLimit( const ELseverityLevel & sv, int n ) {
124  limits.setLimit( sv, n );
125 }
126 
127 
128 void ELdestination::setTimespan( const ELstring & s, int n ) {
129  limits.setTimespan( s, n );
130 }
131 
132 
134  limits.setTimespan( sv, n );
135 }
136 
137 
139 
140 
142 
144  if (moduleName=="*") {
145  ignoreMostModules = false;
146  respondToMostModules = true;
147  ignoreThese.clear();
148  respondToThese.clear();
149  } else {
150  respondToThese.insert(moduleName);
151  ignoreThese.erase(moduleName);
152  }
153 }
154 
156  if (moduleName=="*") {
157  respondToMostModules = false;
158  ignoreMostModules = true;
159  respondToThese.clear();
160  ignoreThese.clear();
161  } else {
162  ignoreThese.insert(moduleName);
163  respondToThese.erase(moduleName);
164  }
165 }
166 
168  ignoreModule("*");
169  respondToModule(moduleName);
170 }
171 
173  respondToModule("*");
174  ignoreModule(moduleName);
175 }
176 
178 
180 
181 
182 void ELdestination::changeFile (std::ostream & /*unused*/) {
183  edm::ErrorObj msg( ELwarning, noosMsg );
184  msg << notELoutputMsg;
185  log( msg );
186 }
187 
189  edm::ErrorObj msg( ELwarning, noosMsg );
190  msg << notELoutputMsg << newline << "file requested is" << filename;
191  log( msg );
192 }
193 
195  edm::ErrorObj msg( ELwarning, noosMsg );
196  msg << "cannot flush()";
197  log( msg );
198 }
199 
200 // ----------------------------------------------------------------------
201 // Output format options:
202 // ----------------------------------------------------------------------
203 
204 void ELdestination::suppressText() { ; } // $$ jvr
206 
209 
212 
215 
218 
221 
224 
227 
230 
232 
234  int temp=lineLength;
235  lineLength = len;
236  return temp;
237 }
238 
239 int ELdestination::getLineLength () const { return lineLength; }
240 
241 
242 // ----------------------------------------------------------------------
243 // Protected helper methods:
244 // ----------------------------------------------------------------------
245 
247  if (respondToMostModules) {
248  return ( ignoreThese.find(s) != ignoreThese.end() );
249  } else if (ignoreMostModules) {
250  return ( respondToThese.find(s) == respondToThese.end() );
251  } else {
252  return false;
253  }
254 }
255 
256 
257 void close_and_delete::operator()(std::ostream* os) const {
258  std::ofstream* p = static_cast<std::ofstream*>(os);
259  p->close();
260  delete os;
261 }
262 
263 } // end of namespace service
264 } // end of namespace edm
ELseverityLevel traceThreshold
virtual void excludeModule(ELstring const &moduleName)
std::unordered_set< std::string > ignoreThese
void setTimespan(const ELstring &s, int n)
virtual void includeSubroutine()
void operator()(std::ostream *os) const
virtual bool thisShouldBeIgnored(const ELstring &s) const
virtual int setLineLength(int len)
static const ELstring noosMsg
static const int defaultLineLength
ELslProxy< ELwarningGen > const ELwarning
ELslProxy< ELhighestSeverityGen > const ELhighestSeverity
virtual int getLineLength() const
virtual void ignoreModule(ELstring const &moduleName)
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
ELslProxy< ELzeroSeverityGen > const ELzeroSeverity
void setThreshold(const ELseverityLevel &sv)
virtual void filterModule(ELstring const &moduleName)
std::unordered_set< std::string > respondToThese
void setTraceThreshold(const ELseverityLevel &sv)
void setInterval(const ELstring &id, int interval)
virtual void suppressSubroutine()
static const ELstring hereMsg
virtual void changeFile(std::ostream &os)
static const ELstring notELoutputMsg
tuple msg
Definition: mps_check.py:277
virtual void respondToModule(ELstring const &moduleName)
HLT enums.
virtual ELstring getNewline() const
virtual bool log(const edm::ErrorObj &msg)
virtual void setTableLimit(int n)
void setTimespan(const ELstring &id, int n)
void setInterval(const ELstring &s, int interval)
std::string ELstring
Definition: ELstring.h:26
void setLimit(const ELstring &id, int n)
void setLimit(const ELstring &s, int n)