CMS 3D CMS Logo

ThreadSafeLogMessageLoggerScribe.h
Go to the documentation of this file.
1 #ifndef FWCore_MessageService_ThreadSafeLogMessageLoggerScribe_h
2 #define FWCore_MessageService_ThreadSafeLogMessageLoggerScribe_h
3 
6 
11 
13 
14 #include <memory>
15 
16 #include <iosfwd>
17 #include <vector>
18 #include <map>
19 
20 #include <iostream>
21 #include <atomic>
22 #include "tbb/concurrent_queue.h"
23 
24 namespace edm {
25  namespace service {
26 
27  // ----------------------------------------------------------------------
28  //
29  // ThreadSafeLogMessageLoggerScribe.h
30  //
31  // OpCodeLOG_A_MESSAGE messages can be handled from multiple threads
32  //
33  // -----------------------------------------------------------------------
34 
35  class ELadministrator;
36  class ELstatistics;
37 
39  public:
40  // --- birth/death:
41 
42  // ChangeLog 12
45 
47 
48  // --- receive and act on messages:
49  // changelog 10
50  void runCommand(MessageLoggerQ::OpCode opcode, void* operand) override;
51  // changeLog 9
52 
53  private:
54  // --- convenience typedefs
56  typedef std::vector<String> vString;
57  typedef ParameterSet PSet;
58 
59  // --- log one consumed message
60  void log(ErrorObj* errorobj_p);
61 
62  // --- cause statistics destinations to output
64  void triggerFJRmessageSummary(std::map<std::string, double>& sm);
65 
66  // --- handle details of configuring via a ParameterSet:
67  void configure_errorlog();
68  void configure_ordinary_destinations(); // Change Log 3
69  void configure_statistics(); // Change Log 3
70  void configure_dest(std::shared_ptr<ELdestination> dest_ctrl, String const& filename);
71 
72  template <class T> // ChangeLog 11
73  T getAparameter(PSet const& p, std::string const& id, T const& def) {
74  T t = def;
75  try {
76  t = p.template getUntrackedParameter<T>(id, def);
77  } catch (...) {
78  try {
79  t = p.template getParameter<T>(id);
80  } catch (...) {
81  // Since PSetValidation will catch such errors, we simply proceed as
82  // best we can in case we are setting up the logger just to contain the
83  // validation-caught error messages.
84  }
85  }
86  return t;
87  }
88 
89  // --- other helpers
90  void parseCategories(std::string const& s, std::vector<std::string>& cats);
91 
92  // --- data:
94  std::shared_ptr<ELdestination> early_dest;
95  std::vector<edm::propagate_const<std::shared_ptr<std::ofstream>>> file_ps;
97  std::map<String, edm::propagate_const<std::ostream*>> stream_ps;
98  std::vector<String> ordinary_destination_filenames;
99  std::vector<std::shared_ptr<ELstatistics>> statisticsDestControls;
100  std::vector<bool> statisticsResets;
103  bool active;
104  std::atomic<bool> purge_mode; // changeLog 9
105  std::atomic<int> count; // changeLog 9
106  std::atomic<bool> m_messageBeingSent;
107  tbb::concurrent_queue<ErrorObj*> m_waitingMessages;
109  std::atomic<unsigned long> m_tooManyWaitingMessagesCount;
110 
111  }; // ThreadSafeLogMessageLoggerScribe
112 
113  } // end of namespace service
114 } // namespace edm
115 
116 #endif // FWCore_MessageService_ThreadSafeLogMessageLoggerScribe_h
void runCommand(MessageLoggerQ::OpCode opcode, void *operand) override
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
void triggerFJRmessageSummary(std::map< std::string, double > &sm)
T getAparameter(PSet const &p, std::string const &id, T const &def)
ThreadSafeLogMessageLoggerScribe()
— If queue is NULL, this sets singleThread true
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
HLT enums.
void configure_dest(std::shared_ptr< ELdestination > dest_ctrl, String const &filename)
void parseCategories(std::string const &s, std::vector< std::string > &cats)
long double T
JetCorrectorParameters::Definitions def
Definition: classes.h:6