test
CMS 3D CMS Logo

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