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 #include <iostream>
28 #include <fstream>
29 
31 
32 // Possible Traces:
33 // #define ELdestinationCONSTRUCTOR_TRACE
34 
35 namespace edm {
36  namespace service {
37  // Fix $001 2/13/01 mf
38 #ifdef DEFECT_NO_STATIC_CONST_INIT
39  const int ELdestination::defaultLineLength = 80;
40 #endif
41 
44  traceThreshold(ELhighestSeverity),
45  limits(),
46  preamble("%MSG"),
47  newline("\n"),
48  indent(" "),
49  lineLength(defaultLineLength),
50  ignoreMostModules(false),
51  respondToThese(),
52  respondToMostModules(false),
53  ignoreThese() {
54 #ifdef ELdestinationCONSTRUCTOR_TRACE
55  std::cerr << "Constructor for ELdestination\n";
56 #endif
57 
58  } // ELdestination()
59 
61 #ifdef ELdestinationCONSTRUCTOR_TRACE
62  std::cerr << "Destructor for ELdestination\n";
63 #endif
64 
65  } // ~ELdestination()
66 
67  // ----------------------------------------------------------------------
68  // Methods invoked by the ELadministrator:
69  // ----------------------------------------------------------------------
70 
71  bool ELdestination::log(const edm::ErrorObj&) { return false; }
72 
73  // ----------------------------------------------------------------------
74  // Methods invoked through the ELdestControl handle:
75  // ----------------------------------------------------------------------
76 
77  // Each of these must be overridden by any destination for which they make
78  // sense. In this base class, where they are all no-ops, the methods which
79  // generate data to a destination, stream or stream will warn at that place,
80  // and all the no-op methods will issue an ELwarning2 at their own destination.
81 
82  static const ELstring hereMsg = "available via this destination";
83  static const ELstring noosMsg = "No ostream";
84  static const ELstring notELoutputMsg = "This destination is not an ELoutput";
85 
86  // ----------------------------------------------------------------------
87  // Behavior control methods invoked by the framework
88  // ----------------------------------------------------------------------
89 
91 
93 
94  void ELdestination::setLimit(const ELstring& s, int n) { limits.setLimit(s, n); }
95 
96  void ELdestination::setInterval(const ELseverityLevel& sv, int interval) { limits.setInterval(sv, interval); }
97 
98  void ELdestination::setInterval(const ELstring& s, int interval) { limits.setInterval(s, interval); }
99 
101 
103 
105 
107 
109 
111  if (moduleName == "*") {
112  ignoreMostModules = false;
113  respondToMostModules = true;
114  ignoreThese.clear();
115  respondToThese.clear();
116  } else {
117  respondToThese.insert(moduleName);
118  ignoreThese.erase(moduleName);
119  }
120  }
121 
123  if (moduleName == "*") {
124  respondToMostModules = false;
125  ignoreMostModules = true;
126  respondToThese.clear();
127  ignoreThese.clear();
128  } else {
129  ignoreThese.insert(moduleName);
130  respondToThese.erase(moduleName);
131  }
132  }
133 
135  ignoreModule("*");
136  respondToModule(moduleName);
137  }
138 
140  respondToModule("*");
141  ignoreModule(moduleName);
142  }
143 
145 
147 
148  void ELdestination::changeFile(std::ostream& /*unused*/) {
149  edm::ErrorObj msg(ELwarning, noosMsg);
150  msg << notELoutputMsg;
151  log(msg);
152  }
153 
155  edm::ErrorObj msg(ELwarning, noosMsg);
156  msg << notELoutputMsg << newline << "file requested is" << filename;
157  log(msg);
158  }
159 
161  edm::ErrorObj msg(ELwarning, noosMsg);
162  msg << "cannot flush()";
163  log(msg);
164  }
165 
166  // ----------------------------------------------------------------------
167  // Output format options:
168  // ----------------------------------------------------------------------
169 
170  void ELdestination::suppressText() { ; } // $$ jvr
172 
175 
178 
181 
184 
187 
190 
193 
196 
198 
200  int temp = lineLength;
201  lineLength = len;
202  return temp;
203  }
204 
205  int ELdestination::getLineLength() const { return lineLength; }
206 
207  // ----------------------------------------------------------------------
208  // Protected helper methods:
209  // ----------------------------------------------------------------------
210 
212  if (respondToMostModules) {
213  return (ignoreThese.find(s) != ignoreThese.end());
214  } else if (ignoreMostModules) {
215  return (respondToThese.find(s) == respondToThese.end());
216  } else {
217  return false;
218  }
219  }
220 
221  void close_and_delete::operator()(std::ostream* os) const {
222  std::ofstream* p = static_cast<std::ofstream*>(os);
223  p->close();
224  delete os;
225  }
226 
227  } // end of namespace service
228 } // 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:279
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:21
void setLimit(const ELstring &id, int n)
void setLimit(const ELstring &s, int n)