MessageLoggerQ.h
Go to the documentation of this file.
1 #ifndef messagefacility_MessageService_MessageLoggerQ_h
2 #define messagefacility_MessageService_MessageLoggerQ_h
3 
7 
8 #include <map>
9 #include <memory>
10 #include <set>
11 #include <string>
12 
13 namespace fhicl {
14  class ParameterSet;
15 }
16 
17 namespace mf {
18 
19  class ErrorObj;
20  class ELdestination;
21  namespace service {
22  class AbstractMLscribe;
23  }
24 
26  public:
27  // --- birth via a surrogate:
28  static MessageLoggerQ* instance();
29 
30  // --- post a message to the queue:
31  static void MLqEND();
32  static void MLqLOG(ErrorObj* p);
33 
34  struct Config {
35  // FIXME: The fact that we explicitly refer to art-provided
36  // program options is a code smell. Somehow, the interaction
37  // between messagefacility and art should be generalized
38  // (probably down to fhiclcpp) so that the implementation for
39  // printing parameter descriptions does not rest in art. In
40  // other words, 'art --print-(available|description)' should
41  // merely forward to a facility that is used to print
42  // messagefacility-, art-, and any other package-provided plugin
43  // descriptions.
45  fhicl::Name{"destinations"},
47  R"(The 'destinations' parameter represents a FHiCL table of named
48 destinations, each of which are configured to specify how messages
49 are logged to a given target. It has the general form of:
50 
51  destinations: {
52  // Ordinary destinations
53  dest1 : {...}
54  dest2 : {...}
55  ...
56  statistics: { // optional
57  // Statistics destinations
58  stat1: {...}
59  ...
60  }
61  }
62 
63 For a listing of allowed ordinary destinations, type:
64 
65  art --print-available mfPlugin
66 
67 The allowed configuration for a given destination type can be printed
68 by specifying:
69 
70  art --print-description mfPlugin:<destination type>
71 
72 It is permitted to specify an ordinary destination called
73 'statistics'. The 'statistics' destination is a FHiCL table that has
74 named statistics destinations, which can be used to encapsulate the
75 configuration related to statistics-tracking of messages logged to a
76 each ordinary destination. To print out the allowed statistics
77 destinations and the allowed configuration corresponding to a given
78 statistics destination, replace the 'mfPlugin' specification with
79 'mfStatsPlugin'.
80 
81 If a value for 'destinations' is not supplied, one will be provided for you.)"}};
82  };
83  static void MLqCFG(Config* p);
84  static void MLqSUM();
85  static void MLqSHT();
86  static void MLqFLS();
87 
88  // --- bookkeeping for single-thread mode
89  static void setMLscribe_ptr(
90  std::unique_ptr<mf::service::AbstractMLscribe> m);
91 
92  // --- special control of standAlone logging behavior
93  static void standAloneThreshold(mf::ELseverityLevel severity);
94  static void squelch(std::string const& category);
95  static bool ignore(mf::ELseverityLevel severity,
96  std::string const& category);
97 
98  // --- Allow the setting of global information.
99  static void setApplication(std::string const& application);
100  static void setHostName(std::string const& name);
101  static void setHostAddr(std::string const& addr);
102  static void setPID(long PID);
103 
104  // --- no copying:
105  MessageLoggerQ(MessageLoggerQ const&) = delete;
106  MessageLoggerQ& operator=(MessageLoggerQ const&) = delete;
107 
108  private:
109  // --- traditional birth/death, but disallowed to users:
110  MessageLoggerQ() = default;
111  ~MessageLoggerQ() = default;
112 
113  // --- place an item onto the queue, or execute the command directly
114  static void simpleCommand(service::OpCode opcode, void* operand);
115  static void handshakedCommand(service::OpCode opcode,
116  void* operand,
117  std::string const& commandMnemonic);
118 
119  // --- data:
120  static std::unique_ptr<mf::service::AbstractMLscribe> mlscribe_ptr;
122  static std::set<std::string> squelchSet;
123 
124  }; // MessageLoggerQ
125 
126 } // namespace mf
127 
128 #endif /* messagefacility_MessageService_MessageLoggerQ_h */
129 
130 // Local Variables:
131 // mode: c++
132 // End:
static const double m
Definition: Units.h:79
std::string string
Definition: nybbler.cc:12
parameter set interface
static mf::ELseverityLevel threshold
static std::set< std::string > squelchSet
static std::unique_ptr< mf::service::AbstractMLscribe > mlscribe_ptr
constexpr std::enable_if_t< are_cv_compatible< TO, FROM >::value, std::add_pointer_t< std::remove_pointer_t< TO > > > addr(FROM &from)
Definition: ensurePointer.h:35