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 
54  static constexpr int NO_VALUE_SET = -45654;
55  static constexpr int COMMON_DEFAULT_LIMIT = NO_VALUE_SET;
56  static constexpr int COMMON_DEFAULT_INTERVAL = NO_VALUE_SET;
57  static constexpr int COMMON_DEFAULT_TIMESPAN = NO_VALUE_SET;
58 
60  int limit_;
62  int timespan_;
66  };
67 
68  private:
70 
71  // --- convenience typedefs
72  using vString = std::vector<std::string>;
73 
74  // --- log one consumed message
75  void log(ErrorObj* errorobj_p);
76 
77  // --- cause statistics destinations to output
79  void triggerFJRmessageSummary(std::map<std::string, double>& sm);
80 
81  // --- handle details of configuring via a ParameterSet:
84  std::vector<std::string> configure_ordinary_destinations(edm::ParameterSet const&,
86  vString const& categories);
89  vString const& categories,
90  std::vector<std::string> const& destination_names);
91  void configure_statistics_dest(edm::ParameterSet const& job_pset,
93  vString const& categories,
94  edm::ParameterSet const& stat_pset,
95  std::string const& psetname,
96  std::string const& filename);
97  void configure_dest(edm::ParameterSet const& job_pset,
98  ConfigurableDefaults const&,
99  vString const& categories,
100  std::shared_ptr<ELdestination> dest_ctrl,
101  edm::ParameterSet const& dest_pset,
102  std::string const& filename);
103 
104  template <class T>
105  static T getAparameter(edm::ParameterSet const& p, std::string const& id, T const& def) {
106  T t = def;
107  try {
108  t = p.template getUntrackedParameter<T>(id, def);
109  } catch (...) {
110  try {
111  t = p.template getParameter<T>(id);
112  } catch (...) {
113  // Since PSetValidation will catch such errors, we simply proceed as
114  // best we can in case we are setting up the logger just to contain the
115  // validation-caught error messages.
116  }
117  }
118  return t;
119  }
120 
121  // --- other helpers
122  void parseCategories(std::string const& s, std::vector<std::string>& cats);
124  std::shared_ptr<ELdestination> makeDestinationCtrl(std::string const& filename);
125 
126  void validate(edm::ParameterSet&) const;
127  // --- data:
129  std::shared_ptr<ELdestination> m_early_dest;
130  std::vector<edm::propagate_const<std::shared_ptr<std::ofstream>>> m_file_ps;
131  std::map<std::string, edm::propagate_const<std::ostream*>> m_stream_ps;
132  std::vector<std::shared_ptr<ELstatistics>> m_statisticsDestControls;
133  std::vector<bool> m_statisticsResets;
136  bool m_active;
137  std::atomic<bool> m_purge_mode;
138  std::atomic<int> m_count;
139  std::atomic<bool> m_messageBeingSent;
140  tbb::concurrent_queue<ErrorObj*> m_waitingMessages;
142  std::atomic<unsigned long> m_tooManyWaitingMessagesCount;
143 
144  }; // ThreadSafeLogMessageLoggerScribe
145 
146  } // end of namespace service
147 } // namespace edm
148 
149 #endif // FWCore_MessageService_ThreadSafeLogMessageLoggerScribe_h
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::reportEvery_
int reportEvery_
Definition: ThreadSafeLogMessageLoggerScribe.h:61
service
Definition: service.py:1
edm::service::AbstractMLscribe
Definition: AbstractMLscribe.h:9
edm::service::ThreadSafeLogMessageLoggerScribe::m_messageLoggerDefaults
value_ptr< MessageLoggerDefaults > m_messageLoggerDefaults
Definition: ThreadSafeLogMessageLoggerScribe.h:135
myMessageLogger_cff.categories
categories
Definition: myMessageLogger_cff.py:10
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::lineLength_
int lineLength_
Definition: ThreadSafeLogMessageLoggerScribe.h:63
propagate_const.h
edm::service::ThreadSafeLogMessageLoggerScribe::triggerStatisticsSummaries
void triggerStatisticsSummaries()
Definition: ThreadSafeLogMessageLoggerScribe.cc:872
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::ErrorObj
Definition: ErrorObj.h:43
edm::service::ThreadSafeLogMessageLoggerScribe::m_admin_p
edm::propagate_const< std::shared_ptr< ELadministrator > > m_admin_p
Definition: ThreadSafeLogMessageLoggerScribe.h:128
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::NO_VALUE_SET
static constexpr int NO_VALUE_SET
Definition: ThreadSafeLogMessageLoggerScribe.h:54
edm::service::ThreadSafeLogMessageLoggerScribe::log
void log(ErrorObj *errorobj_p)
Definition: ThreadSafeLogMessageLoggerScribe.cc:160
edm::service::ThreadSafeLogMessageLoggerScribe::parseDefaults
static ConfigurableDefaults parseDefaults(edm::ParameterSet const &job_pset)
Definition: ThreadSafeLogMessageLoggerScribe.cc:431
edm::service::ThreadSafeLogMessageLoggerScribe::m_messageBeingSent
std::atomic< bool > m_messageBeingSent
Definition: ThreadSafeLogMessageLoggerScribe.h:139
edm::service::ThreadSafeLogMessageLoggerScribe::configure_statistics
void configure_statistics(edm::ParameterSet const &, ConfigurableDefaults const &defaults, vString const &categories, std::vector< std::string > const &destination_names)
Definition: ThreadSafeLogMessageLoggerScribe.cc:733
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults
Definition: ThreadSafeLogMessageLoggerScribe.h:53
edm::service::ThreadSafeLogMessageLoggerScribe::m_clean_slate_configuration
bool m_clean_slate_configuration
Definition: ThreadSafeLogMessageLoggerScribe.h:134
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::timespan_
int timespan_
Definition: ThreadSafeLogMessageLoggerScribe.h:62
edm::service::ThreadSafeLogMessageLoggerScribe::parseCategories
void parseCategories(std::string const &s, std::vector< std::string > &cats)
Definition: ThreadSafeLogMessageLoggerScribe.cc:857
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::propagate_const
Definition: propagate_const.h:32
edm::service::ThreadSafeLogMessageLoggerScribe::configure_dest
void configure_dest(edm::ParameterSet const &job_pset, ConfigurableDefaults const &, vString const &categories, std::shared_ptr< ELdestination > dest_ctrl, edm::ParameterSet const &dest_pset, std::string const &filename)
Definition: ThreadSafeLogMessageLoggerScribe.cc:452
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::limit_
int limit_
Definition: ThreadSafeLogMessageLoggerScribe.h:60
edm::service::ThreadSafeLogMessageLoggerScribe::getAparameter
static T getAparameter(edm::ParameterSet const &p, std::string const &id, T const &def)
Definition: ThreadSafeLogMessageLoggerScribe.h:105
edm::service::ThreadSafeLogMessageLoggerScribe::triggerFJRmessageSummary
void triggerFJRmessageSummary(std::map< std::string, double > &sm)
Definition: ThreadSafeLogMessageLoggerScribe.cc:881
edm::service::ThreadSafeLogMessageLoggerScribe::makeDestinationCtrl
std::shared_ptr< ELdestination > makeDestinationCtrl(std::string const &filename)
Definition: ThreadSafeLogMessageLoggerScribe.cc:396
MessageLoggerQ.h
edm::service::ThreadSafeLogMessageLoggerScribe::m_waitingThreshold
size_t m_waitingThreshold
Definition: ThreadSafeLogMessageLoggerScribe.h:141
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
edm::service::ThreadSafeLogMessageLoggerScribe::configure_errorlog_new
void configure_errorlog_new(edm::ParameterSet &)
Definition: ThreadSafeLogMessageLoggerScribe.cc:279
edm::service::ThreadSafeLogMessageLoggerScribe::configure_statistics_dest
void configure_statistics_dest(edm::ParameterSet const &job_pset, ConfigurableDefaults const &defaults, vString const &categories, edm::ParameterSet const &stat_pset, std::string const &psetname, std::string const &filename)
Definition: ThreadSafeLogMessageLoggerScribe.cc:699
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::COMMON_DEFAULT_TIMESPAN
static constexpr int COMMON_DEFAULT_TIMESPAN
Definition: ThreadSafeLogMessageLoggerScribe.h:57
value_ptr.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
AbstractMLscribe.h
ELdestination.h
l1GtPatternGenerator_cfi.defaults
defaults
Definition: l1GtPatternGenerator_cfi.py:93
edm::service::ThreadSafeLogMessageLoggerScribe::m_stream_ps
std::map< std::string, edm::propagate_const< std::ostream * > > m_stream_ps
Definition: ThreadSafeLogMessageLoggerScribe.h:131
edm::ParameterSet
Definition: ParameterSet.h:47
edm::value_ptr
Definition: value_ptr.h:63
edm::service::ThreadSafeLogMessageLoggerScribe::ThreadSafeLogMessageLoggerScribe
ThreadSafeLogMessageLoggerScribe()
— If queue is NULL, this sets singleThread true
Definition: ThreadSafeLogMessageLoggerScribe.cc:40
edm::service::ThreadSafeLogMessageLoggerScribe::m_waitingMessages
tbb::concurrent_queue< ErrorObj * > m_waitingMessages
Definition: ThreadSafeLogMessageLoggerScribe.h:140
edm::service::ThreadSafeLogMessageLoggerScribe::m_count
std::atomic< int > m_count
Definition: ThreadSafeLogMessageLoggerScribe.h:138
edm::service::ThreadSafeLogMessageLoggerScribe::m_early_dest
std::shared_ptr< ELdestination > m_early_dest
Definition: ThreadSafeLogMessageLoggerScribe.h:129
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::threshold_
std::string threshold_
Definition: ThreadSafeLogMessageLoggerScribe.h:59
edm::service::ThreadSafeLogMessageLoggerScribe::runCommand
void runCommand(MessageLoggerQ::OpCode opcode, void *operand) override
Definition: ThreadSafeLogMessageLoggerScribe.cc:70
edm::service::ThreadSafeLogMessageLoggerScribe::m_statisticsDestControls
std::vector< std::shared_ptr< ELstatistics > > m_statisticsDestControls
Definition: ThreadSafeLogMessageLoggerScribe.h:132
edm::service::ThreadSafeLogMessageLoggerScribe
Definition: ThreadSafeLogMessageLoggerScribe.h:38
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::noTimeStamps_
bool noTimeStamps_
Definition: ThreadSafeLogMessageLoggerScribe.h:65
edm::service::ThreadSafeLogMessageLoggerScribe::m_tooManyWaitingMessagesCount
std::atomic< unsigned long > m_tooManyWaitingMessagesCount
Definition: ThreadSafeLogMessageLoggerScribe.h:142
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::COMMON_DEFAULT_LIMIT
static constexpr int COMMON_DEFAULT_LIMIT
Definition: ThreadSafeLogMessageLoggerScribe.h:55
T
long double T
Definition: Basic3DVectorLD.h:48
edm::service::ThreadSafeLogMessageLoggerScribe::configure_errorlog
void configure_errorlog(edm::ParameterSet &)
Definition: ThreadSafeLogMessageLoggerScribe.cc:355
edm::service::ThreadSafeLogMessageLoggerScribe::destinationFileName
std::string destinationFileName(edm::ParameterSet const &, std::string const &) const
Definition: ThreadSafeLogMessageLoggerScribe.cc:244
edm::service::ThreadSafeLogMessageLoggerScribe::vString
std::vector< std::string > vString
Definition: ThreadSafeLogMessageLoggerScribe.h:72
edm::service::ThreadSafeLogMessageLoggerScribe::~ThreadSafeLogMessageLoggerScribe
~ThreadSafeLogMessageLoggerScribe() override
Definition: ThreadSafeLogMessageLoggerScribe.cc:51
edm::service::ThreadSafeLogMessageLoggerScribe::validate
void validate(edm::ParameterSet &) const
Definition: ThreadSafeLogMessageLoggerScribe.cc:971
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::COMMON_DEFAULT_INTERVAL
static constexpr int COMMON_DEFAULT_INTERVAL
Definition: ThreadSafeLogMessageLoggerScribe.h:56
edm::service::ThreadSafeLogMessageLoggerScribe::configure_ordinary_destinations
std::vector< std::string > configure_ordinary_destinations(edm::ParameterSet const &, ConfigurableDefaults const &defaults, vString const &categories)
Definition: ThreadSafeLogMessageLoggerScribe.cc:622
spu::def
int def(FILE *, FILE *, int)
Definition: SherpackUtilities.cc:14
ParameterSet.h
edm::service::ThreadSafeLogMessageLoggerScribe::m_file_ps
std::vector< edm::propagate_const< std::shared_ptr< std::ofstream > > > m_file_ps
Definition: ThreadSafeLogMessageLoggerScribe.h:130
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
MessageLoggerDefaults.h
edm::service::ThreadSafeLogMessageLoggerScribe::m_active
bool m_active
Definition: ThreadSafeLogMessageLoggerScribe.h:136
edm::service::ThreadSafeLogMessageLoggerScribe::m_purge_mode
std::atomic< bool > m_purge_mode
Definition: ThreadSafeLogMessageLoggerScribe.h:137
edm::service::ThreadSafeLogMessageLoggerScribe::m_statisticsResets
std::vector< bool > m_statisticsResets
Definition: ThreadSafeLogMessageLoggerScribe.h:133
edm::MessageLoggerQ::OpCode
OpCode
Definition: MessageLoggerQ.h:29
edm::service::ThreadSafeLogMessageLoggerScribe::ConfigurableDefaults::noLineBreaks_
bool noLineBreaks_
Definition: ThreadSafeLogMessageLoggerScribe.h:64