MessageLoggerScribe.h
Go to the documentation of this file.
1 #ifndef messagefacility_MessageLogger_MessageLoggerScribe_h
2 #define messagefacility_MessageLogger_MessageLoggerScribe_h
3 
5 #include "cetlib/exempt_ptr.h"
13 
14 #include <atomic>
15 #include <iosfwd>
16 #include <map>
17 #include <memory>
18 #include <vector>
19 
20 #include "tbb/concurrent_queue.h"
21 
22 namespace mf {
23  namespace service {
24 
26  public:
28  MessageLoggerScribe(std::string const& applicationName);
29 
32 
33  // --- receive and act on messages:
34  void runCommand(OpCode opcode, void* operand) override;
35 
36  // Set context items.
37  void setApplication(std::string const& application) override;
38  void setHostName(std::string const& hostName) override;
39  void setHostAddr(std::string const& hostAddr) override;
40  void setPID(long pid) override;
41 
42  private:
43  // --- log one consumed message
44  void log(ErrorObj* errorobj_p);
45 
46  // --- cause statistics destinations to output
48 
49  // --- handle details of configuring via a ParameterSet:
50  void configure_errorlog(
51  std::unique_ptr<MessageLoggerQ::Config>&& dests_config);
52 
53  void fetchDestinations(
54  std::unique_ptr<MessageLoggerQ::Config> dests_config);
57 
58  // --- other helpers
59  std::vector<std::string> parseCategories(std::string const& s);
60 
61  // --- data:
67  bool active_{true};
68  std::atomic<bool> purgeMode_{false};
69  std::atomic<int> count_{0};
70  std::atomic<bool> messageBeingSent_{false};
71  tbb::concurrent_queue<ErrorObj*> waitingMessages_{};
72 
73  std::string createId(std::set<std::string>& existing_ids,
74  std::string const& type,
75  std::string const& filename,
76  fhicl::ParameterSet const& pset = {},
77  bool const should_throw = true);
78 
79  bool duplicateDestination(std::string const& output_id,
80  ELdestConfig::dest_config const config,
81  bool const should_throw);
82 
83  std::unique_ptr<ELdestination> makePlugin_(
84  cet::BasicPluginFactory& pluginFactory,
85  std::string const& libspec,
86  std::string const& psetname,
87  fhicl::ParameterSet const& pset);
88 
89  }; // MessageLoggerScribe
90 
91  } // end of namespace service
92 } // namespace mf
93 
94 #endif /* messagefacility_MessageLogger_MessageLoggerScribe_h */
95 
96 // Local Variables:
97 // mode: c++
98 // End:
std::string string
Definition: nybbler.cc:12
void configure_errorlog(std::unique_ptr< MessageLoggerQ::Config > &&dests_config)
void runCommand(OpCode opcode, void *operand) override
MessageLoggerScribe(std::string const &applicationName)
cet::BasicPluginFactory pluginFactory_
list dests
Define destination.
std::string createId(std::set< std::string > &existing_ids, std::string const &type, std::string const &filename, fhicl::ParameterSet const &pset={}, bool const should_throw=true)
std::vector< std::string > parseCategories(std::string const &s)
cet::BasicPluginFactory pluginStatsFactory_
void setHostName(std::string const &hostName) override
std::unique_ptr< ELdestination > makePlugin_(cet::BasicPluginFactory &pluginFactory, std::string const &libspec, std::string const &psetname, fhicl::ParameterSet const &pset)
MessageLoggerScribe & operator=(MessageLoggerScribe const &)=delete
void log(ErrorObj *errorobj_p)
tbb::concurrent_queue< ErrorObj * > waitingMessages_
void setApplication(std::string const &application) override
bool duplicateDestination(std::string const &output_id, ELdestConfig::dest_config const config, bool const should_throw)
static const double s
Definition: Units.h:99
void setHostAddr(std::string const &hostAddr) override
void fetchDestinations(std::unique_ptr< MessageLoggerQ::Config > dests_config)
void makeDestinations(fhicl::ParameterSet const &dests, ELdestConfig::dest_config const config)