CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 using namespace edm::messagelogger;
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 
43  ELdestination::ELdestination()
45  traceThreshold(ELhighestSeverity),
46  limits(),
47  preamble("%MSG"),
48  newline("\n"),
49  indent(" "),
50  lineLength(defaultLineLength),
51  respondToMostModules(false),
52  ignoreMostModules(false),
53  respondToThese(),
54  ignoreThese() {
55 #ifdef ELdestinationCONSTRUCTOR_TRACE
56  std::cerr << "Constructor for ELdestination\n";
57 #endif
58 
59  } // ELdestination()
60 
62 #ifdef ELdestinationCONSTRUCTOR_TRACE
63  std::cerr << "Destructor for ELdestination\n";
64 #endif
65 
66  } // ~ELdestination()
67 
68  // ----------------------------------------------------------------------
69  // Methods invoked by the ELadministrator:
70  // ----------------------------------------------------------------------
71 
72  bool ELdestination::log(const edm::ErrorObj&) { return false; }
73 
74  // ----------------------------------------------------------------------
75  // Methods invoked through the ELdestControl handle:
76  // ----------------------------------------------------------------------
77 
78  // Each of these must be overridden by any destination for which they make
79  // sense. In this base class, where they are all no-ops, the methods which
80  // generate data to a destination, stream or stream will warn at that place,
81  // and all the no-op methods will issue an ELwarning2 at their own destination.
82 
83  static const std::string hereMsg = "available via this destination";
84  static const std::string noosMsg = "No ostream";
85  static const std::string notELoutputMsg = "This destination is not an ELoutput";
86 
87  // ----------------------------------------------------------------------
88  // Behavior control methods invoked by the framework
89  // ----------------------------------------------------------------------
90 
92 
94 
95  void ELdestination::setLimit(const std::string& s, int n) { limits.setLimit(s, n); }
96 
97  void ELdestination::setInterval(const ELseverityLevel& sv, int interval) { limits.setInterval(sv, interval); }
98 
99  void ELdestination::setInterval(const std::string& s, int interval) { limits.setInterval(s, interval); }
100 
101  void ELdestination::setLimit(const ELseverityLevel& sv, int n) { limits.setLimit(sv, n); }
102 
104 
105  void ELdestination::setTimespan(const ELseverityLevel& sv, int n) { limits.setTimespan(sv, n); }
106 
108 
110 
112  if (moduleName == "*") {
113  ignoreMostModules = false;
114  respondToMostModules = true;
115  ignoreThese.clear();
116  respondToThese.clear();
117  } else {
118  respondToThese.insert(moduleName);
119  ignoreThese.erase(moduleName);
120  }
121  }
122 
124  if (moduleName == "*") {
125  respondToMostModules = false;
126  ignoreMostModules = true;
127  respondToThese.clear();
128  ignoreThese.clear();
129  } else {
130  ignoreThese.insert(moduleName);
131  respondToThese.erase(moduleName);
132  }
133  }
134 
136  ignoreModule("*");
137  respondToModule(moduleName);
138  }
139 
141  respondToModule("*");
142  ignoreModule(moduleName);
143  }
144 
146 
148 
149  void ELdestination::changeFile(std::ostream& /*unused*/) {
151  msg << notELoutputMsg;
152  log(msg);
153  }
154 
157  msg << notELoutputMsg << newline << "file requested is" << filename;
158  log(msg);
159  }
160 
163  msg << "cannot flush()";
164  log(msg);
165  }
166 
167  // ----------------------------------------------------------------------
168  // Output format options:
169  // ----------------------------------------------------------------------
170 
171  void ELdestination::suppressText() { ; } // $$ jvr
173 
176 
179 
182 
185 
188 
191 
194 
197 
199 
201  int temp = lineLength;
202  lineLength = len;
203  return temp;
204  }
205 
206  int ELdestination::getLineLength() const { return lineLength; }
207 
208  // ----------------------------------------------------------------------
209  // Protected helper methods:
210  // ----------------------------------------------------------------------
211 
213  if (respondToMostModules) {
214  return (ignoreThese.find(s) != ignoreThese.end());
215  } else if (ignoreMostModules) {
216  return (respondToThese.find(s) == respondToThese.end());
217  } else {
218  return false;
219  }
220  }
221 
222  void close_and_delete::operator()(std::ostream* os) const {
223  std::ofstream* p = static_cast<std::ofstream*>(os);
224  p->close();
225  delete os;
226  }
227 
228  } // end of namespace service
229 } // end of namespace edm
constexpr const ELseverityLevel ELwarning
void setLimit(const std::string &id, int n)
constexpr const ELseverityLevel ELzeroSeverity
std::unordered_set< std::string > ignoreThese
virtual void includeSubroutine()
tuple interval
Definition: MergeJob_cfg.py:20
void operator()(std::ostream *os) const
virtual int setLineLength(int len)
void setThreshold(const messagelogger::ELseverityLevel &sv)
static const std::string hereMsg
virtual void filterModule(std::string const &moduleName)
virtual void respondToModule(std::string const &moduleName)
void setTimespan(const std::string &id, int n)
virtual void ignoreModule(std::string const &moduleName)
void setInterval(const std::string &id, int interval)
virtual int getLineLength() const
virtual bool thisShouldBeIgnored(std::string const &s) const
void setInterval(const std::string &s, int interval)
std::unordered_set< std::string > respondToThese
virtual void suppressSubroutine()
virtual void changeFile(std::ostream &os)
tuple msg
Definition: mps_check.py:285
virtual void excludeModule(std::string const &moduleName)
std::string moduleName(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:27
void setTraceThreshold(const messagelogger::ELseverityLevel &sv)
void setTimespan(const std::string &s, int n)
static const std::string noosMsg
tuple filename
Definition: lut2db_cfg.py:20
constexpr const ELseverityLevel ELhighestSeverity
messagelogger::ELseverityLevel traceThreshold
void setLimit(const std::string &s, int n)
virtual std::string getNewline() const
virtual bool log(const edm::ErrorObj &msg)
messagelogger::ELseverityLevel threshold
virtual void setTableLimit(int n)
static const std::string notELoutputMsg