1 #include "cetlib/PluginTypeDeducer.h"
2 #include "fhiclcpp/ParameterSet.h"
3 #if MESSAGEFACILITY_HEX_VERSION >= 0x20106 // v2_01_06 => cetlib v3_02_00 => new clang support
4 #include "cetlib/ProvideMakePluginMacros.h"
7 #include "messagefacility/MessageService/ELdestination.h"
8 #include "messagefacility/Utilities/ELseverityLevel.h"
9 #include "messagefacility/Utilities/exception.h"
10 #include "cetlib/compiler_macros.h"
12 #define TRACE_NAME "MessageFacility"
14 #if GCC_VERSION >= 701000 || defined(__clang__)
15 #pragma GCC diagnostic push
16 #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
21 #if GCC_VERSION >= 701000 || defined(__clang__)
22 #pragma GCC diagnostic pop
28 using mf::service::ELdestination;
29 using mf::ELseverityLevel;
38 #if MESSAGEFACILITY_HEX_VERSION >= 0x20103
41 fhicl::TableFragment<ELdestination::Config> elDestConfig;
42 fhicl::Atom<size_t> lvls{ fhicl::Name{
"lvls" },fhicl::Comment{
"TRACE level mask for Slow output" },0 };
43 fhicl::Atom<size_t> lvlm{ fhicl::Name{
"lvlm" },fhicl::Comment{
"TRACE level mask for Memory output" },0 };
45 using Parameters = fhicl::WrappedTable<Config>;
54 #if MESSAGEFACILITY_HEX_VERSION < 0x20103 // v2_01_03 is s58, pre v2_01_03 is s50
55 ELTRACE(
const fhicl::ParameterSet& pset);
57 ELTRACE(Parameters
const& pset);
65 virtual void fillPrefix(std::ostringstream& o,
const ErrorObj& e)
override;
72 virtual void fillUsrMsg(std::ostringstream& o,
const ErrorObj& e)
override;
77 virtual void fillSuffix(std::ostringstream&,
const ErrorObj&)
override {}
84 virtual void routePayload(
const std::ostringstream& o,
const ErrorObj& e)
override;
96 #if MESSAGEFACILITY_HEX_VERSION < 0x20103
102 if (pset.get_if_present<
size_t>(
"lvls", msk))
103 TRACE_CNTL(
"lvlmskS", msk);
105 if (pset.get_if_present<
size_t>(
"lvlm", msk))
106 TRACE_CNTL(
"lvlmskM", msk);
108 TLOG(TLVL_INFO) <<
"ELTRACE MessageLogger destination plugin initialized.";
112 : ELdestination(pset().elDestConfig())
116 if (pset().lvls() != 0)
119 TRACE_CNTL(
"lvlmskS", msk);
121 if (pset().lvlm() != 0)
124 TRACE_CNTL(
"lvlmskM", msk);
127 TLOG(TLVL_INFO) <<
"ELTRACE MessageLogger destination plugin initialized.";
137 const auto& xid = msg.xid();
139 oss << xid.application() <<
", ";
140 oss << xid.id() <<
": ";
150 std::ostringstream tmposs;
151 ELdestination::fillUsrMsg(tmposs, msg);
154 const std::string& usrMsg = !tmposs.str().compare(0, 1,
"\n") ? tmposs.str().erase(0, 1) : tmposs.str();
164 const auto& xid = msg.xid();
165 auto message = oss.str();
167 auto level = xid.severity().getLevel();
172 case mf::ELseverityLevel::ELsev_success:
173 case mf::ELseverityLevel::ELsev_zeroSeverity:
174 case mf::ELseverityLevel::ELsev_unspecified:
178 case mf::ELseverityLevel::ELsev_info:
182 case mf::ELseverityLevel::ELsev_warning:
186 TRACE(lvlNum, message);
196 #ifndef EXTERN_C_FUNC_DECLARE_START
197 #define EXTERN_C_FUNC_DECLARE_START extern "C" {
200 EXTERN_C_FUNC_DECLARE_START
201 auto makePlugin(
const std::string&,
202 const fhicl::ParameterSet& pset)
204 return std::make_unique<mfplugins::ELTRACE>(pset);
208 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
ELTRACE(const fhicl::ParameterSet &pset)
ELTRACE Constructor
virtual void fillPrefix(std::ostringstream &o, const ErrorObj &e) override
Fill the "Prefix" portion of the message.
virtual void fillSuffix(std::ostringstream &, const ErrorObj &) override
Fill the "Suffix" portion of the message (Unused)