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
service
Definition: service.py:1
edm::service::AbstractMLscribe
Definition: AbstractMLscribe.h:9
edm::service::ThreadSafeLogMessageLoggerScribe::configure_statistics
void configure_statistics()
Definition: ThreadSafeLogMessageLoggerScribe.cc:553
edm::service::ThreadSafeLogMessageLoggerScribe::ordinary_destination_filenames
std::vector< String > ordinary_destination_filenames
Definition: ThreadSafeLogMessageLoggerScribe.h:98
propagate_const.h
edm::service::ThreadSafeLogMessageLoggerScribe::triggerStatisticsSummaries
void triggerStatisticsSummaries()
Definition: ThreadSafeLogMessageLoggerScribe.cc:696
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::service::ThreadSafeLogMessageLoggerScribe::file_ps
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > file_ps
Definition: ThreadSafeLogMessageLoggerScribe.h:95
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::ErrorObj
Definition: ErrorObj.h:44
edm::service::ThreadSafeLogMessageLoggerScribe::log
void log(ErrorObj *errorobj_p)
Definition: ThreadSafeLogMessageLoggerScribe.cc:161
edm::service::ThreadSafeLogMessageLoggerScribe::statisticsDestControls
std::vector< std::shared_ptr< ELstatistics > > statisticsDestControls
Definition: ThreadSafeLogMessageLoggerScribe.h:99
edm::service::ThreadSafeLogMessageLoggerScribe::stream_ps
std::map< String, edm::propagate_const< std::ostream * > > stream_ps
Definition: ThreadSafeLogMessageLoggerScribe.h:97
edm::service::ThreadSafeLogMessageLoggerScribe::m_messageBeingSent
std::atomic< bool > m_messageBeingSent
Definition: ThreadSafeLogMessageLoggerScribe.h:106
edm::service::ThreadSafeLogMessageLoggerScribe::getAparameter
T getAparameter(PSet const &p, std::string const &id, T const &def)
Definition: ThreadSafeLogMessageLoggerScribe.h:73
edm::service::ThreadSafeLogMessageLoggerScribe::job_pset_p
edm::propagate_const< std::shared_ptr< PSet > > job_pset_p
Definition: ThreadSafeLogMessageLoggerScribe.h:96
edm::service::ThreadSafeLogMessageLoggerScribe::early_dest
std::shared_ptr< ELdestination > early_dest
Definition: ThreadSafeLogMessageLoggerScribe.h:94
edm::service::ThreadSafeLogMessageLoggerScribe::configure_errorlog
void configure_errorlog()
Definition: ThreadSafeLogMessageLoggerScribe.cc:193
edm::service::ThreadSafeLogMessageLoggerScribe::parseCategories
void parseCategories(std::string const &s, std::vector< std::string > &cats)
Definition: ThreadSafeLogMessageLoggerScribe.cc:681
edm::service::ThreadSafeLogMessageLoggerScribe::purge_mode
std::atomic< bool > purge_mode
Definition: ThreadSafeLogMessageLoggerScribe.h:104
edm::service::ThreadSafeLogMessageLoggerScribe::admin_p
edm::propagate_const< std::shared_ptr< ELadministrator > > admin_p
Definition: ThreadSafeLogMessageLoggerScribe.h:93
edm::service::ThreadSafeLogMessageLoggerScribe::active
bool active
Definition: ThreadSafeLogMessageLoggerScribe.h:103
edm::service::ThreadSafeLogMessageLoggerScribe::configure_dest
void configure_dest(std::shared_ptr< ELdestination > dest_ctrl, String const &filename)
Definition: ThreadSafeLogMessageLoggerScribe.cc:219
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::propagate_const
Definition: propagate_const.h:32
edm::service::ThreadSafeLogMessageLoggerScribe::triggerFJRmessageSummary
void triggerFJRmessageSummary(std::map< std::string, double > &sm)
Definition: ThreadSafeLogMessageLoggerScribe.cc:705
edm::service::ThreadSafeLogMessageLoggerScribe::statisticsResets
std::vector< bool > statisticsResets
Definition: ThreadSafeLogMessageLoggerScribe.h:100
MessageLoggerQ.h
edm::service::ThreadSafeLogMessageLoggerScribe::m_waitingThreshold
size_t m_waitingThreshold
Definition: ThreadSafeLogMessageLoggerScribe.h:108
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
OrderedSet.t
t
Definition: OrderedSet.py:90
value_ptr.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
AbstractMLscribe.h
ELdestination.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::value_ptr
Definition: value_ptr.h:63
edm::service::ThreadSafeLogMessageLoggerScribe::ThreadSafeLogMessageLoggerScribe
ThreadSafeLogMessageLoggerScribe()
— If queue is NULL, this sets singleThread true
Definition: ThreadSafeLogMessageLoggerScribe.cc:38
edm::service::ThreadSafeLogMessageLoggerScribe::m_waitingMessages
tbb::concurrent_queue< ErrorObj * > m_waitingMessages
Definition: ThreadSafeLogMessageLoggerScribe.h:107
edm::service::ThreadSafeLogMessageLoggerScribe::String
std::string String
Definition: ThreadSafeLogMessageLoggerScribe.h:55
edm::service::ThreadSafeLogMessageLoggerScribe::runCommand
void runCommand(MessageLoggerQ::OpCode opcode, void *operand) override
Definition: ThreadSafeLogMessageLoggerScribe.cc:72
edm::service::ThreadSafeLogMessageLoggerScribe
Definition: ThreadSafeLogMessageLoggerScribe.h:38
edm::service::ThreadSafeLogMessageLoggerScribe::m_tooManyWaitingMessagesCount
std::atomic< unsigned long > m_tooManyWaitingMessagesCount
Definition: ThreadSafeLogMessageLoggerScribe.h:109
edm::service::ThreadSafeLogMessageLoggerScribe::vString
std::vector< String > vString
Definition: ThreadSafeLogMessageLoggerScribe.h:56
T
long double T
Definition: Basic3DVectorLD.h:48
edm::service::ThreadSafeLogMessageLoggerScribe::~ThreadSafeLogMessageLoggerScribe
~ThreadSafeLogMessageLoggerScribe() override
Definition: ThreadSafeLogMessageLoggerScribe.cc:53
edm::service::ThreadSafeLogMessageLoggerScribe::PSet
ParameterSet PSet
Definition: ThreadSafeLogMessageLoggerScribe.h:57
spu::def
int def(FILE *, FILE *, int)
Definition: SherpackUtilities.cc:14
edm::service::ThreadSafeLogMessageLoggerScribe::configure_ordinary_destinations
void configure_ordinary_destinations()
Definition: ThreadSafeLogMessageLoggerScribe.cc:434
ParameterSet.h
MessageLoggerDefaults.h
edm::service::ThreadSafeLogMessageLoggerScribe::messageLoggerDefaults
value_ptr< MessageLoggerDefaults > messageLoggerDefaults
Definition: ThreadSafeLogMessageLoggerScribe.h:102
edm::service::ThreadSafeLogMessageLoggerScribe::clean_slate_configuration
bool clean_slate_configuration
Definition: ThreadSafeLogMessageLoggerScribe.h:101
edm::MessageLoggerQ::OpCode
OpCode
Definition: MessageLoggerQ.h:26
edm::service::ThreadSafeLogMessageLoggerScribe::count
std::atomic< int > count
Definition: ThreadSafeLogMessageLoggerScribe.h:105