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 {
40 public:
41  // --- birth/death:
42 
43  // ChangeLog 12
46 
48 
49  // --- receive and act on messages:
50  virtual // changelog 10
51  void runCommand(MessageLoggerQ::OpCode opcode, void * operand);
52  // changeLog 9
53 
54 private:
55  // --- convenience typedefs
57  typedef std::vector<String> vString;
58  typedef ParameterSet PSet;
59 
60  // --- log one consumed message
61  void log(ErrorObj * errorobj_p);
62 
63  // --- cause statistics destinations to output
65  void triggerFJRmessageSummary(std::map<std::string, double> & sm);
66 
67  // --- handle details of configuring via a ParameterSet:
68  void configure_errorlog( );
69  void configure_ordinary_destinations( ); // Change Log 3
70  void configure_statistics( ); // Change Log 3
71  void configure_dest( std::shared_ptr<ELdestination> dest_ctrl
72  , String const & filename
73  );
74 
75  template <class T> // ChangeLog 11
76  T getAparameter ( PSet const& p, std::string const & id, T const & def )
77  {
78  T t = def;
79  try {
80  t = p.template getUntrackedParameter<T>(id, def);
81  } catch (...) {
82  try {
83  t = p.template getParameter<T>(id);
84  } catch (...) {
85  // Since PSetValidation will catch such errors, we simply proceed as
86  // best we can in case we are setting up the logger just to contain the
87  // validation-caught error messages.
88  }
89  }
90  return t;
91  }
92 
93  // --- other helpers
94  void parseCategories (std::string const & s, std::vector<std::string> & cats);
95 
96  // --- data:
98  std::shared_ptr<ELdestination> early_dest;
99  std::vector<edm::propagate_const<std::shared_ptr<std::ofstream>>> file_ps;
101  std::map<String, edm::propagate_const<std::ostream*>> stream_ps;
102  std::vector<String> ordinary_destination_filenames;
103  std::vector<std::shared_ptr<ELstatistics>> statisticsDestControls;
104  std::vector<bool> statisticsResets;
107  bool active;
108  std::atomic<bool> purge_mode; // changeLog 9
109  std::atomic<int> count; // changeLog 9
110  std::atomic<bool> m_messageBeingSent;
111  tbb::concurrent_queue<ErrorObj*> m_waitingMessages;
113  std::atomic<unsigned long> m_tooManyWaitingMessagesCount;
114 
115 }; // ThreadSafeLogMessageLoggerScribe
116 
117 
118 } // end of namespace service
119 } // namespace edm
120 
121 
122 #endif // FWCore_MessageService_ThreadSafeLogMessageLoggerScribe_h
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
virtual void runCommand(MessageLoggerQ::OpCode opcode, void *operand)
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