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  public:
88  // --- birth/death:
89 
90  // ChangeLog 12
92  explicit MessageLoggerScribe(std::shared_ptr<ThreadQueue> queue);
93 
94  ~MessageLoggerScribe() override;
95 
96  // --- receive and act on messages:
97  virtual void run();
98  // changelog 10
99  void runCommand(MessageLoggerQ::OpCode opcode, void* operand) override;
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(std::shared_ptr<ELdestination> dest_ctrl, String const& filename);
120 
121 #define VALIDATE_ELSEWHERE // ChangeLog 11
122 
123 #ifdef OLDSTYLE
124  template <class T>
125  T getAparameter(PSet const& p, std::string const& id, T const& def) {
126  T t;
127  try {
128  t = p.template getUntrackedParameter<T>(id, def);
129  } catch (...) {
130  t = p.template getParameter<T>(id);
131  std::cerr << "Tracked parameter " << id << " used in MessageLogger configuration.\n"
132  << "Use of tracked parameters for the message service "
133  << "is deprecated.\n"
134  << "The .cfg file should be modified to make this untracked.\n";
135  }
136  return t;
137  }
138 #else
139 #ifdef SIMPLESTYLE
140  template <class T>
141  T getAparameter(PSet const& p, std::string const& id, T const& def) {
142  T t;
143  t = p.template getUntrackedParameter<T>(id, def);
144  return t;
145  } // changelog 2
146 #else
147 #ifdef VALIDATE_ELSEWHERE
148  template <class T> // ChangeLog 11
149  T getAparameter(PSet const& p, std::string const& id, T const& def) {
150  T t = def;
151  try {
152  t = p.template getUntrackedParameter<T>(id, def);
153  } catch (...) {
154  try {
155  t = p.template getParameter<T>(id);
156  } catch (...) {
157  // Since PSetValidation will catch such errors, we simply proceed as
158  // best we can in case we are setting up the logger just to contain the
159  // validation-caught error messages.
160  }
161  }
162  return t;
163  }
164 #else // Do not tolerate errors
165  template <class T>
166  T getAparameter(PSet const& p, std::string const& id, T const& def) { // changelog 7
167  T t;
168  try {
169  t = p.template getUntrackedParameter<T>(id, def);
170  } catch (cms::Exception& e) {
171  try {
172  t = p.template getParameter<T>(id);
173  } catch (...) {
174  // if we get here, this was NOT a simple tracked parameter goof.
175  // we should just rethrow the ORIGINAL error
176  e.raise();
177  }
178  std::cerr << "Tracked parameter " << id << " used in MessageLogger configuration.\n"
179  << "Use of tracked parameters for the message service "
180  << "is not allowed.\n"
181  << "The .cfg file should be modified to make this untracked.\n";
182  e.raise();
183  } catch (...) {
184  // This is not the usual tracked/untracked error; we can't add useful info
185  throw;
186  }
187  return t;
188  }
189 
190 #endif // VALIDATE_ELSEWHERE
191 #endif // SIMPLESTYLE
192 #endif // OLD_STYLE and the else Do not tolerate errors
193 
194 #ifdef REMOVE
195  template <class T>
196  T getCategoryDefault(PSet* p, std::string const& id, std::string const& def) {
197  T t;
198  t = p->template getUntrackedParameter<T>(id, def);
199  return t;
200  }
201 #endif
202 
203  // --- other helpers
204  void parseCategories(std::string const& s, std::vector<std::string>& cats);
205 
206  // --- data:
208  std::shared_ptr<ELdestination> early_dest;
209  std::vector<edm::propagate_const<std::shared_ptr<std::ofstream>>> file_ps;
211  std::map<String, edm::propagate_const<std::ostream*>> stream_ps;
212  std::vector<String> ordinary_destination_filenames;
213  std::vector<std::shared_ptr<ELstatistics>> statisticsDestControls;
214  std::vector<bool> statisticsResets;
217  bool active;
218  bool singleThread; // changeLog 9
219  bool done; // changeLog 9
220  bool purge_mode; // changeLog 9
221  int count; // changeLog 9
223 
224  }; // MessageLoggerScribe
225 
226  } // end of namespace service
227 } // namespace edm
228 
229 #endif // FWCore_MessageService_MessageLoggerScribe_h
service
Definition: service.py:1
edm::service::AbstractMLscribe
Definition: AbstractMLscribe.h:9
edm::service::MessageLoggerScribe::statisticsDestControls
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
Definition: MessageLoggerScribe.h:213
edm::service::MessageLoggerScribe::admin_p
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
Definition: MessageLoggerScribe.h:207
propagate_const.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::service::MessageLoggerScribe::run
virtual void run()
Definition: MessageLoggerScribe.cc:232
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::ErrorObj
Definition: ErrorObj.h:44
edm::service::MessageLoggerScribe::MessageLoggerScribe
MessageLoggerScribe(std::shared_ptr< ThreadQueue > queue)
— If queue is NULL, this sets singleThread true
Definition: MessageLoggerScribe.cc:212
edm::service::MessageLoggerScribe::purge_mode
bool purge_mode
Definition: MessageLoggerScribe.h:220
edm::service::MessageLoggerScribe::clean_slate_configuration
bool clean_slate_configuration
Definition: MessageLoggerScribe.h:215
edm::service::MessageLoggerScribe::configure_statistics
void configure_statistics()
Definition: MessageLoggerScribe.cc:761
edm::service::MessageLoggerScribe::file_ps
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
Definition: MessageLoggerScribe.h:209
edm::service::MessageLoggerScribe::String
std::string String
Definition: MessageLoggerScribe.h:104
edm::service::MessageLoggerScribe::configure_errorlog
void configure_errorlog()
Definition: MessageLoggerScribe.cc:392
edm::service::MessageLoggerScribe::~MessageLoggerScribe
~MessageLoggerScribe() override
Definition: MessageLoggerScribe.cc:230
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::propagate_const
Definition: propagate_const.h:32
edm::service::MessageLoggerScribe::singleThread
bool singleThread
Definition: MessageLoggerScribe.h:218
edm::service::MessageLoggerScribe::configure_ordinary_destinations
void configure_ordinary_destinations()
Definition: MessageLoggerScribe.cc:640
edm::service::MessageLoggerScribe::vString
std::vector< String > vString
Definition: MessageLoggerScribe.h:105
MessageLoggerQ.h
edm::service::MessageLoggerScribe::parseCategories
void parseCategories(std::string const &s, std::vector< std::string > &cats)
Definition: MessageLoggerScribe.cc:889
edm::service::MessageLoggerScribe
Definition: MessageLoggerScribe.h:86
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
OrderedSet.t
t
Definition: OrderedSet.py:90
createBeamHaloJobs.queue
queue
Definition: createBeamHaloJobs.py:343
value_ptr.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
AbstractMLscribe.h
edm::service::MessageLoggerScribe::triggerStatisticsSummaries
void triggerStatisticsSummaries()
Definition: MessageLoggerScribe.cc:904
ELdestination.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::service::MessageLoggerScribe::active
bool active
Definition: MessageLoggerScribe.h:217
edm::service::MessageLoggerScribe::stream_ps
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
Definition: MessageLoggerScribe.h:211
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
edm::value_ptr
Definition: value_ptr.h:63
edm::service::MessageLoggerScribe::PSet
ParameterSet PSet
Definition: MessageLoggerScribe.h:106
edm::service::MessageLoggerScribe::job_pset_p
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
Definition: MessageLoggerScribe.h:210
edm::service::MessageLoggerScribe::statisticsResets
std::vector< bool > statisticsResets
Definition: MessageLoggerScribe.h:214
edm::service::MessageLoggerScribe::count
int count
Definition: MessageLoggerScribe.h:221
edm::service::MessageLoggerScribe::messageLoggerDefaults
value_ptr< MessageLoggerDefaults > messageLoggerDefaults
Definition: MessageLoggerScribe.h:216
edm::service::MessageLoggerScribe::done
bool done
Definition: MessageLoggerScribe.h:219
edm::service::MessageLoggerScribe::m_queue
edm::propagate_const< std::shared_ptr< ThreadQueue > > m_queue
Definition: MessageLoggerScribe.h:222
edm::service::MessageLoggerScribe::triggerFJRmessageSummary
void triggerFJRmessageSummary(std::map< std::string, double > &sm)
Definition: MessageLoggerScribe.cc:913
T
long double T
Definition: Basic3DVectorLD.h:48
edm::service::MessageLoggerScribe::configure_dest
void configure_dest(std::shared_ptr< ELdestination > dest_ctrl, String const &filename)
Definition: MessageLoggerScribe.cc:426
edm::service::MessageLoggerScribe::getAparameter
T getAparameter(PSet const &p, std::string const &id, T const &def)
Definition: MessageLoggerScribe.h:149
edm::service::MessageLoggerScribe::ordinary_destination_filenames
std::vector< String > ordinary_destination_filenames
Definition: MessageLoggerScribe.h:212
spu::def
int def(FILE *, FILE *, int)
Definition: SherpackUtilities.cc:14
cms::Exception
Definition: Exception.h:70
ParameterSet.h
edm::service::MessageLoggerScribe::runCommand
void runCommand(MessageLoggerQ::OpCode opcode, void *operand) override
Definition: MessageLoggerScribe.cc:249
edm::service::MessageLoggerScribe::log
void log(ErrorObj *errorobj_p)
Definition: MessageLoggerScribe.cc:383
MessageLoggerDefaults.h
edm::MessageLoggerQ::OpCode
OpCode
Definition: MessageLoggerQ.h:26
ThreadQueue
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::service::MessageLoggerScribe::early_dest
std::shared_ptr< ELdestination > early_dest
Definition: MessageLoggerScribe.h:208