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 
33 
34 // Possible Traces:
35 // #define ELdestinationCONSTRUCTOR_TRACE
36 
37 namespace edm {
38 namespace service {
39  // Fix $001 2/13/01 mf
40 #ifdef DEFECT_NO_STATIC_CONST_INIT
41  const int ELdestination::defaultLineLength = 80;
42 #endif
43 
46 , traceThreshold( ELhighestSeverity )
47 , limits ( )
48 , preamble ( "%MSG" )
49 , newline ( "\n" )
50 , indent ( " " )
51 , lineLength ( defaultLineLength )
52 , ignoreMostModules (false)
53 , respondToThese()
54 , respondToMostModules (false)
55 , ignoreThese()
56 {
57 
58  #ifdef ELdestinationCONSTRUCTOR_TRACE
59  std::cerr << "Constructor for ELdestination\n";
60  #endif
61 
62 } // ELdestination()
63 
64 
66 
67  #ifdef ELdestinationCONSTRUCTOR_TRACE
68  std::cerr << "Destructor for ELdestination\n";
69  #endif
70 
71 } // ~ELdestination()
72 
73 
74 // ----------------------------------------------------------------------
75 // Methods invoked by the ELadministrator:
76 // ----------------------------------------------------------------------
77 
78 bool ELdestination::log( const edm::ErrorObj &) { return false; }
79 
80 
81 // ----------------------------------------------------------------------
82 // Methods invoked through the ELdestControl handle:
83 // ----------------------------------------------------------------------
84 
85 // Each of these must be overridden by any destination for which they make
86 // sense. In this base class, where they are all no-ops, the methods which
87 // generate data to a destination, stream or stream will warn at that place,
88 // and all the no-op methods will issue an ELwarning2 at their own destination.
89 
90 
91 static const ELstring noSummarizationMsg = "No summarization()";
92 static const ELstring noSummaryMsg = "No summary()";
93 static const ELstring noClearSummaryMsg = "No clearSummary()";
94 static const ELstring hereMsg = "available via this destination";
95 static const ELstring noosMsg = "No ostream";
96 static const ELstring notELoutputMsg = "This destination is not an ELoutput";
97 
99 
100  edm::ErrorObj msg( ELwarning, noClearSummaryMsg );
101  msg << hereMsg;
102  log( msg );
103 
104 } // clearSummary()
105 
106 
108 
109 
111 
113  if (moduleName=="*") {
114  ignoreMostModules = false;
115  respondToMostModules = true;
116  ignoreThese.clear();
117  respondToThese.clear();
118  } else {
119  respondToThese.insert(moduleName);
120  ignoreThese.erase(moduleName);
121  }
122 }
123 
125  if (moduleName=="*") {
126  respondToMostModules = false;
127  ignoreMostModules = true;
128  respondToThese.clear();
129  ignoreThese.clear();
130  } else {
131  ignoreThese.insert(moduleName);
132  respondToThese.erase(moduleName);
133  }
134 }
135 
137  ignoreModule("*");
138  respondToModule(moduleName);
139 }
140 
142  respondToModule("*");
143  ignoreModule(moduleName);
144 }
145 
147 
149 
150  edm::ErrorObj msg( ELwarning, noSummaryMsg );
151  msg << noSummaryMsg << " " << hereMsg << dest.getNewline() << title;
152  dest.log( msg );
153 
154 } // summary()
155 
156 
157 void ELdestination::summary( std::ostream & os, const ELstring & title ) {
158 
159  os << "%MSG" << ELwarning.getSymbol() << " "
160  << noSummaryMsg << " " << hereMsg << std::endl
161  << title << std::endl;
162 
163 } // summary()
164 
165 
167 
168  s = ELstring("%MSG") + ELwarning.getSymbol() + " "
169  + noSummaryMsg + " " + hereMsg + "\n"
170  + title + "\n";
171 
172 } // summary()
173 
174 void ELdestination::summaryForJobReport(std::map<std::string, double> &) { }
175 
177 
179 
180 
182  const ELstring & title
183 , const ELstring & /*sumLines*/ ) {
184 
185  edm::ErrorObj msg( ELwarning, noSummarizationMsg );
186  msg << hereMsg << newline << title;
187  log( msg );
188 
189 }
190 
191 std::map<ELextendedID , StatsCount> ELdestination::statisticsMap() const {
192  return std::map<ELextendedID , StatsCount> ();
193 }
194 
195 void ELdestination::changeFile (std::ostream & /*unused*/) {
196  edm::ErrorObj msg( ELwarning, noosMsg );
197  msg << notELoutputMsg;
198  log( msg );
199 }
200 
202  edm::ErrorObj msg( ELwarning, noosMsg );
203  msg << notELoutputMsg << newline << "file requested is" << filename;
204  log( msg );
205 }
206 
208  edm::ErrorObj msg( ELwarning, noosMsg );
209  msg << "cannot flush()";
210  log( msg );
211 }
212 
213 // ----------------------------------------------------------------------
214 // Output format options:
215 // ----------------------------------------------------------------------
216 
217 void ELdestination::suppressText() { ; } // $$ jvr
219 
222 
225 
228 
231 
234 
237 
240 
243 
245 
247 
249  int temp=lineLength;
250  lineLength = len;
251  return temp;
252 }
253 
254 int ELdestination::getLineLength () const { return lineLength; }
255 
256 
257 // ----------------------------------------------------------------------
258 // Protected helper methods:
259 // ----------------------------------------------------------------------
260 
262  if (respondToMostModules) {
263  return ( ignoreThese.find(s) != ignoreThese.end() );
264  } else if (ignoreMostModules) {
265  return ( respondToThese.find(s) == respondToThese.end() );
266  } else {
267  return false;
268  }
269 }
270 
271 
272 void close_and_delete::operator()(std::ostream* os) const {
273  std::ofstream* p = static_cast<std::ofstream*>(os);
274  p->close();
275  delete os;
276 }
277 
278 } // end of namespace service
279 } // end of namespace edm
virtual void excludeModule(ELstring const &moduleName)
ELstring getNewline() const
virtual void includeSubroutine()
void operator()(std::ostream *os) const
virtual bool thisShouldBeIgnored(const ELstring &s) const
bool log(edm::ErrorObj &msg)
virtual int setLineLength(int len)
virtual void summaryForJobReport(std::map< std::string, double > &sm)
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
virtual void summarization(const edm::ELstring &title, const edm::ELstring &sumLines)
virtual void filterModule(ELstring const &moduleName)
virtual void noTerminationSummary()
virtual std::map< ELextendedID, StatsCount > statisticsMap() const
virtual void suppressSubroutine()
static const ELstring hereMsg
static const ELstring noClearSummaryMsg
virtual void changeFile(std::ostream &os)
static const ELstring notELoutputMsg
static const ELstring noSummarizationMsg
virtual void respondToModule(ELstring const &moduleName)
HLT enums.
virtual ELstring getNewline() const
static const ELstring noSummaryMsg
virtual bool log(const edm::ErrorObj &msg)
virtual void setTableLimit(int n)
std::string ELstring
Definition: ELstring.h:26