CMS 3D CMS Logo

MessageLoggerScribe.h
Go to the documentation of this file.
1 #ifndef FWCore_MessageService_MessageLoggerScribe_h
2 #define FWCore_MessageService_MessageLoggerScribe_h
3 
6 
11 
13 
14 #include <memory>
15 
16 #include <iosfwd>
17 #include <vector>
18 #include <map>
19 
20 #include <iostream>
21 
22 namespace edm {
23 namespace service {
24 
25 // ----------------------------------------------------------------------
26 //
27 // MessageLoggerScribe.h
28 //
29 // Changes:
30 //
31 // 1 - 2/6/07 mf
32 // Set up ability to get a remembered pointer to the ErrorLog of an
33 // instance of MessageLoggerScribe, from a non-member function, via
34 // getErrorLog_ptr(), and a corresponding routine to remember the pointer
35 // as setStaticErrorLog_ptr(). Needed if we decide to send an explicit
36 // message from the scribe.
37 //
38 // 2 - ?/?/? before 3/1/07 jm
39 // Modify parameter getting template so as not to catch tracked ones
40 // (that is, to crash if user mistakenly does not say untracked)
41 //
42 // 3 - 3/13/07 mf
43 // Added configure_ordinary_destinations, configure_fwkJobReports,
44 // and configure_statistics to allow these to be broken out of
45 // configure_errorlog.
46 //
47 // 4 - 3/26/07 mf
48 // Added configure_default_fwkJobReport, which implements the config
49 // originally placed in the .cfi file.
50 //
51 // 5 - 6/15/07 mf
52 // Accommodations for use of MessageLoggerDefault structure
53 //
54 // 6 - 7/24/07 mf
55 // Instace variable indicating that we really are logging what is sent.
56 // This is to be able to supress the <generator> info sent at exit by
57 // the JobReport, in the case where no .cfg file was given.
58 //
59 // 7 - 4/8/08 mf
60 // Modified getAparameter behavior when tracked parameter is found,
61 // for nicer output message.
62 //
63 // 8 - 6/19/08 mf
64 // triggerFJRmessageSummary
65 //
66 // 9 - 10/21/08 mf
67 // variables and routines in preparation for single-thread
68 //
69 // 10 - 10/22/08 mf
70 // derivation from AbstractMLscribe to allow for single-thread calling
71 // from MessageLoggerQ without introducing coupling to MessageService
72 //
73 // 11 - 5/26/09 mf
74 // restore getAparameter behavior to NOT throw for tracked, since
75 // now this will be caught when validating the PSet.
76 //
77 // 12 - 8/10/09 mf, cj
78 // member data to hold shared pointer to thread queue
79 //
80 // -----------------------------------------------------------------------
81 
82 class ThreadQueue;
83 class ELadministrator;
84 class ELstatistics;
85 
87 {
88 public:
89  // --- birth/death:
90 
91  // ChangeLog 12
93  explicit MessageLoggerScribe(std::shared_ptr<ThreadQueue> queue);
94 
95  ~MessageLoggerScribe() override;
96 
97  // --- receive and act on messages:
98  virtual
99  void run();
100  // changelog 10
101  void runCommand(MessageLoggerQ::OpCode opcode, void * operand) override;
102  // changeLog 9
103 
104 private:
105  // --- convenience typedefs
107  typedef std::vector<String> vString;
109 
110  // --- log one consumed message
111  void log(ErrorObj * errorobj_p);
112 
113  // --- cause statistics destinations to output
115  void triggerFJRmessageSummary(std::map<std::string, double> & sm);
116 
117  // --- handle details of configuring via a ParameterSet:
118  void configure_errorlog( );
119  void configure_ordinary_destinations( ); // Change Log 3
120  void configure_statistics( ); // Change Log 3
121  void configure_dest( std::shared_ptr<ELdestination> dest_ctrl
122  , String const & filename
123  );
124 
125 #define VALIDATE_ELSEWHERE // ChangeLog 11
126 
127 #ifdef OLDSTYLE
128  template <class T>
129  T getAparameter ( PSet const& p, std::string const & id, T const & def )
130  {
131  T t;
132  try {
133  t = p.template getUntrackedParameter<T>(id, def);
134  } catch (...) {
135  t = p.template getParameter<T>(id);
136  std::cerr << "Tracked parameter " << id
137  << " used in MessageLogger configuration.\n"
138  << "Use of tracked parameters for the message service "
139  << "is deprecated.\n"
140  << "The .cfg file should be modified to make this untracked.\n";
141  }
142  return t;
143  }
144 #else
145 #ifdef SIMPLESTYLE
146  template <class T>
147  T getAparameter ( PSet const& p, std::string const & id, T const & def )
148  {
149  T t;
150  t = p.template getUntrackedParameter<T>(id, def);
151  return t;
152  } // changelog 2
153 #else
154 #ifdef VALIDATE_ELSEWHERE
155  template <class T> // ChangeLog 11
156  T getAparameter ( PSet const& p, std::string const & id, T const & def )
157  {
158  T t = def;
159  try {
160  t = p.template getUntrackedParameter<T>(id, def);
161  } catch (...) {
162  try {
163  t = p.template getParameter<T>(id);
164  } catch (...) {
165  // Since PSetValidation will catch such errors, we simply proceed as
166  // best we can in case we are setting up the logger just to contain the
167  // validation-caught error messages.
168  }
169  }
170  return t;
171  }
172 #else // Do not tolerate errors
173  template <class T>
174  T getAparameter ( PSet const& p, std::string const & id, T const & def )
175  { // changelog 7
176  T t;
177  try {
178  t = p.template getUntrackedParameter<T>(id, def);
179  } catch (cms::Exception& e) {
180  try {
181  t = p.template getParameter<T>(id);
182  } catch (...) {
183  // if we get here, this was NOT a simple tracked parameter goof.
184  // we should just rethrow the ORIGINAL error
185  e.raise();
186  }
187  std::cerr << "Tracked parameter " << id
188  << " used in MessageLogger configuration.\n"
189  << "Use of tracked parameters for the message service "
190  << "is not allowed.\n"
191  << "The .cfg file should be modified to make this untracked.\n";
192  e.raise();
193  } catch (...) {
194  // This is not the usual tracked/untracked error; we can't add useful info
195  throw;
196  }
197  return t;
198  }
199 
200 #endif // VALIDATE_ELSEWHERE
201 #endif // SIMPLESTYLE
202 #endif // OLD_STYLE and the else Do not tolerate errors
203 
204 #ifdef REMOVE
205  template <class T>
206  T getCategoryDefault ( PSet * p,
207  std::string const & id,
208  std::string const & def )
209  {
210  T t;
211  t = p->template getUntrackedParameter<T>(id, def);
212  return t;
213  }
214 #endif
215 
216 
217  // --- other helpers
218  void parseCategories (std::string const & s, std::vector<std::string> & cats);
219 
220  // --- data:
222  std::shared_ptr<ELdestination> early_dest;
223  std::vector<edm::propagate_const<std::shared_ptr<std::ofstream>>> file_ps;
225  std::map<String,edm::propagate_const<std::ostream*>> stream_ps;
226  std::vector<String> ordinary_destination_filenames;
227  std::vector<std::shared_ptr<ELstatistics>> statisticsDestControls;
228  std::vector<bool> statisticsResets;
231  bool active;
232  bool singleThread; // changeLog 9
233  bool done; // changeLog 9
234  bool purge_mode; // changeLog 9
235  int count; // changeLog 9
237 
238 }; // MessageLoggerScribe
239 
240 
241 } // end of namespace service
242 } // namespace edm
243 
244 
245 #endif // FWCore_MessageService_MessageLoggerScribe_h
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
void raise()
Definition: Exception.h:104
std::vector< String > ordinary_destination_filenames
void runCommand(MessageLoggerQ::OpCode opcode, void *operand) override
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
void configure_dest(std::shared_ptr< ELdestination > dest_ctrl, String const &filename)
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
std::shared_ptr< ELdestination > early_dest
void parseCategories(std::string const &s, std::vector< std::string > &cats)
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
MessageLoggerScribe(std::shared_ptr< ThreadQueue > queue)
— If queue is NULL, this sets singleThread true
HLT enums.
void triggerFJRmessageSummary(std::map< std::string, double > &sm)
T getAparameter(PSet const &p, std::string const &id, T const &def)
edm::propagate_const< std::shared_ptr< ThreadQueue > > m_queue
long double T
JetCorrectorParameters::Definitions def
Definition: classes.h:6
value_ptr< MessageLoggerDefaults > messageLoggerDefaults