1 #include "cetlib/PluginTypeDeducer.h"
2 #include "cetlib/ProvideMakePluginMacros.h"
3 #include "fhiclcpp/ParameterSet.h"
5 #include "cetlib/compiler_macros.h"
6 #include "messagefacility/MessageService/ELdestination.h"
7 #include "messagefacility/Utilities/ELseverityLevel.h"
8 #include "messagefacility/Utilities/exception.h"
10 #define TRACE_NAME "MessageFacility"
12 #if GCC_VERSION >= 701000 || defined(__clang__)
13 #pragma GCC diagnostic push
14 #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
19 #if GCC_VERSION >= 701000 || defined(__clang__)
20 #pragma GCC diagnostic pop
24 using mf::ELseverityLevel;
26 using mf::service::ELdestination;
33 fhicl::TableFragment<ELdestination::Config> elDestConfig;
34 fhicl::Atom<size_t> lvls{fhicl::Name{
"lvls"}, fhicl::Comment{
"TRACE level mask for Slow output"}, 0};
35 fhicl::Atom<size_t> lvlm{fhicl::Name{
"lvlm"}, fhicl::Comment{
"TRACE level mask for Memory output"}, 0};
37 using Parameters = fhicl::WrappedTable<Config>;
44 ELTRACE(Parameters
const& pset);
51 virtual void fillPrefix(std::ostringstream& o,
const ErrorObj& e)
override;
58 virtual void fillUsrMsg(std::ostringstream& o,
const ErrorObj& e)
override;
63 virtual void fillSuffix(std::ostringstream&,
const ErrorObj&)
override {}
70 virtual void routePayload(
const std::ostringstream& o,
const ErrorObj& e)
override;
83 if (pset().lvls() != 0) {
85 TRACE_CNTL(
"lvlmskS", msk);
87 if (pset().lvlm() != 0) {
89 TRACE_CNTL(
"lvlmskM", msk);
92 TLOG(TLVL_INFO) <<
"ELTRACE MessageLogger destination plugin initialized.";
99 const auto& xid = msg.xid();
101 oss << xid.application() <<
", ";
102 oss << xid.id() <<
": ";
111 std::ostringstream tmposs;
112 ELdestination::fillUsrMsg(tmposs, msg);
115 const std::string& usrMsg = !tmposs.str().compare(0, 1,
"\n") ? tmposs.str().erase(0, 1) : tmposs.str();
124 const auto& xid = msg.xid();
125 auto message = oss.str();
127 auto level = xid.severity().getLevel();
131 case mf::ELseverityLevel::ELsev_success:
132 case mf::ELseverityLevel::ELsev_zeroSeverity:
133 case mf::ELseverityLevel::ELsev_unspecified:
137 case mf::ELseverityLevel::ELsev_info:
141 case mf::ELseverityLevel::ELsev_warning:
145 TRACE(lvlNum, message);
155 #ifndef EXTERN_C_FUNC_DECLARE_START
156 #define EXTERN_C_FUNC_DECLARE_START extern "C" {
159 EXTERN_C_FUNC_DECLARE_START
160 auto makePlugin(
const std::string&,
const fhicl::ParameterSet& pset) {
161 return std::make_unique<mfplugins::ELTRACE>(pset);
165 DEFINE_BASIC_PLUGINTYPE_FUNC(mf::service::ELdestination)
virtual void routePayload(const std::ostringstream &o, const ErrorObj &e) override
Serialize a MessageFacility message to the output.
virtual void fillUsrMsg(std::ostringstream &o, const ErrorObj &e) override
Fill the "User Message" portion of the message.
Message Facility destination which logs messages to a TRACE buffer
virtual void fillPrefix(std::ostringstream &o, const ErrorObj &e) override
Fill the "Prefix" portion of the message.
ELTRACE(Parameters const &pset)
ELTRACE Constructor
virtual void fillSuffix(std::ostringstream &, const ErrorObj &) override
Fill the "Suffix" portion of the message (Unused)