1 #include "cetlib/PluginTypeDeducer.h"
2 #include "cetlib/ProvideMakePluginMacros.h"
3 #include "fhiclcpp/ParameterSet.h"
4 #include "fhiclcpp/types/ConfigurationTable.h"
6 #include "cetlib/compiler_macros.h"
7 #include "messagefacility/MessageService/ELdestination.h"
8 #include "messagefacility/Utilities/ELseverityLevel.h"
9 #include "messagefacility/Utilities/exception.h"
11 #define TRACE_NAME "MessageFacility"
13 #if GCC_VERSION >= 701000 || defined(__clang__)
14 #pragma GCC diagnostic push
15 #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
18 #include "TRACE/trace.h"
20 #if GCC_VERSION >= 701000 || defined(__clang__)
21 #pragma GCC diagnostic pop
25 using mf::ELseverityLevel;
27 using mf::service::ELdestination;
44 fhicl::Atom<size_t>{fhicl::Name{
"lvls"}, fhicl::Comment{
"TRACE level mask for Slow output"}, 0};
47 fhicl::Atom<size_t>{fhicl::Name{
"lvlm"}, fhicl::Comment{
"TRACE level mask for Memory output"}, 0};
64 void fillPrefix(std::ostringstream& o,
const ErrorObj& msg)
override;
71 void fillUsrMsg(std::ostringstream& o,
const ErrorObj& msg)
override;
76 void fillSuffix(std::ostringstream& ,
const ErrorObj& )
override {}
83 void routePayload(
const std::ostringstream& o,
const ErrorObj& msg)
override;
94 : ELdestination(pset().elDestConfig())
98 if (pset().lvls() != 0)
101 TRACE_CNTL(
"lvlmskS", msk);
103 if (pset().lvlm() != 0)
106 TRACE_CNTL(
"lvlmskM", msk);
109 TLOG(TLVL_INFO) <<
"ELTRACE MessageLogger destination plugin initialized.";
117 const auto& xid = msg.xid();
119 oss << xid.application() <<
", ";
120 oss << xid.id() <<
": ";
130 std::ostringstream tmposs;
131 ELdestination::fillUsrMsg(tmposs, msg);
134 const std::string& usrMsg = tmposs.str().compare(0, 1,
"\n") == 0 ? tmposs.str().erase(0, 1) : tmposs.str();
144 const auto& xid = msg.xid();
145 auto message = oss.str();
147 auto level = xid.severity().getLevel();
152 case mf::ELseverityLevel::ELsev_success:
153 case mf::ELseverityLevel::ELsev_zeroSeverity:
154 case mf::ELseverityLevel::ELsev_unspecified:
158 case mf::ELseverityLevel::ELsev_info:
162 case mf::ELseverityLevel::ELsev_warning:
168 TRACE(lvlNum, message);
178 #ifndef EXTERN_C_FUNC_DECLARE_START
179 #define EXTERN_C_FUNC_DECLARE_START extern "C" {
182 EXTERN_C_FUNC_DECLARE_START
183 auto makePlugin(
const std::string& ,
const fhicl::ParameterSet& pset)
185 return std::make_unique<mfplugins::ELTRACE>(pset);
189 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.