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;
43 fhicl::Atom<size_t>{fhicl::Name{
"lvls"}, fhicl::Comment{
"TRACE level mask for Slow output"}, 0};
46 fhicl::Atom<size_t>{fhicl::Name{
"lvlm"}, fhicl::Comment{
"TRACE level mask for Memory output"}, 0};
63 void fillPrefix(std::ostringstream& o,
const ErrorObj& msg)
override;
70 void fillUsrMsg(std::ostringstream& o,
const ErrorObj& msg)
override;
75 void fillSuffix(std::ostringstream& ,
const ErrorObj& )
override {}
82 void routePayload(
const std::ostringstream& o,
const ErrorObj& msg)
override;
93 : ELdestination(pset().elDestConfig())
97 if (pset().lvls() != 0)
100 TRACE_CNTL(
"lvlmskS", msk);
102 if (pset().lvlm() != 0)
105 TRACE_CNTL(
"lvlmskM", msk);
108 TLOG(TLVL_INFO) <<
"ELTRACE MessageLogger destination plugin initialized.";
116 const auto& xid = msg.xid();
118 oss << xid.application() <<
", ";
119 oss << xid.id() <<
": ";
129 std::ostringstream tmposs;
130 ELdestination::fillUsrMsg(tmposs, msg);
133 const std::string& usrMsg = tmposs.str().compare(0, 1,
"\n") == 0 ? tmposs.str().erase(0, 1) : tmposs.str();
143 const auto& xid = msg.xid();
144 auto message = oss.str();
146 auto level = xid.severity().getLevel();
151 case mf::ELseverityLevel::ELsev_success:
152 case mf::ELseverityLevel::ELsev_zeroSeverity:
153 case mf::ELseverityLevel::ELsev_unspecified:
157 case mf::ELseverityLevel::ELsev_info:
161 case mf::ELseverityLevel::ELsev_warning:
167 TRACE(lvlNum, message);
177 #ifndef EXTERN_C_FUNC_DECLARE_START
178 #define EXTERN_C_FUNC_DECLARE_START extern "C" {
181 EXTERN_C_FUNC_DECLARE_START
182 auto makePlugin(
const std::string& ,
const fhicl::ParameterSet& pset)
184 return std::make_unique<mfplugins::ELTRACE>(pset);
188 DEFINE_BASIC_PLUGINTYPE_FUNC(mf::service::ELdestination)
void fillPrefix(std::ostringstream &o, const ErrorObj &msg) override
Fill the "Prefix" portion of the message.
void fillSuffix(std::ostringstream &, const ErrorObj &) override
Fill the "Suffix" portion of the message (Unused)
Message Facility destination which logs messages to a TRACE buffer
fhicl::TableFragment< ELdestination::Config > elDestConfig
ELDestination common parameters.
ELTRACE(Parameters const &pset)
ELTRACE Constructor
Configuration Parameters for ELTRACE.
fhicl::Atom< size_t > lvlm
"lvlm" (Default: 0): TRACE level mask for Memory output
void fillUsrMsg(std::ostringstream &o, const ErrorObj &msg) override
Fill the "User Message" portion of the message.
fhicl::Atom< size_t > lvls
"lvls" (Default: 0): TRACE level mask for Slow output
fhicl::WrappedTable< Config > Parameters
Used for ParameterSet validation.
void routePayload(const std::ostringstream &o, const ErrorObj &msg) override
Serialize a MessageFacility message to the output.