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 #if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
10 # include "messagefacility/MessageService/ELcontextSupplier.h"
11 # include "messagefacility/MessageLogger/MessageDrop.h"
13 #include "messagefacility/Utilities/exception.h"
15 #define TRACE_NAME "MessageFacility"
21 using mf::service::ELdestination;
22 using mf::ELseverityLevel;
23 # if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
24 using mf::service::ELcontextSupplier;
34 #if MESSAGEFACILITY_HEX_VERSION >= 0x20103
37 fhicl::TableFragment<ELdestination::Config> elDestConfig;
38 fhicl::Atom<size_t> lvls{ fhicl::Name{
"lvls" },fhicl::Comment{
"TRACE level mask for Slow output" },0 };
39 fhicl::Atom<size_t> lvlm{ fhicl::Name{
"lvlm" },fhicl::Comment{
"TRACE level mask for Memory output" },0 };
41 using Parameters = fhicl::WrappedTable<Config>;
46 #if MESSAGEFACILITY_HEX_VERSION < 0x20103 // v2_01_03 is s58, pre v2_01_03 is s50
47 ELTRACE(
const fhicl::ParameterSet& pset);
49 ELTRACE(Parameters
const& pset);
52 virtual void fillPrefix(std::ostringstream&,
const ErrorObj&
53 #
if MESSAGEFACILITY_HEX_VERSION < 0x20002
54 ,
const ELcontextSupplier&
58 virtual void fillUsrMsg(std::ostringstream&,
const ErrorObj&)
override;
60 virtual void fillSuffix(std::ostringstream&,
const ErrorObj&)
override {}
62 virtual void routePayload(
const std::ostringstream&,
const ErrorObj&
63 #
if MESSAGEFACILITY_HEX_VERSION < 0x20002
64 ,
const ELcontextSupplier&
78 #if MESSAGEFACILITY_HEX_VERSION < 0x20103
79 ELTRACE::ELTRACE(
const fhicl::ParameterSet& pset)
84 if (pset.get_if_present<
size_t>(
"lvls",msk))
85 TRACE_CNTL(
"lvlmskS",msk);
87 if (pset.get_if_present<
size_t>(
"lvlm",msk))
88 TRACE_CNTL(
"lvlmskM",msk);
90 TRACE(3,
"ELTRACE MessageLogger destination plugin initialized.");
93 ELTRACE::ELTRACE(Parameters
const& pset)
94 : ELdestination(pset().elDestConfig())
98 if (pset().lvls() != 0) {
100 TRACE_CNTL(
"lvlmskS", msk);
102 if (pset().lvlm() != 0)
105 TRACE_CNTL(
"lvlmskM", msk);
108 TRACE(3,
"ELTRACE MessageLogger destination plugin initialized.");
116 void ELTRACE::fillPrefix(std::ostringstream& oss,
const ErrorObj& msg
117 #
if MESSAGEFACILITY_HEX_VERSION < 0x20002
118 , ELcontextSupplier
const&
122 const auto& xid = msg.xid();
124 # if MESSAGEFACILITY_HEX_VERSION >= 0x20002 // an indication of a switch from s48 to s50
125 oss << xid.application() <<
", ";
126 oss << xid.id() <<
": ";
128 oss << xid.application <<
", ";
129 oss << xid.id <<
": ";
138 void ELTRACE::fillUsrMsg(std::ostringstream& oss,
const ErrorObj& msg)
140 std::ostringstream tmposs;
141 ELdestination::fillUsrMsg(tmposs, msg);
144 const std::string& usrMsg = !tmposs.str().compare(0, 1,
"\n") ? tmposs.str().erase(0, 1) : tmposs.str();
152 void ELTRACE::routePayload(
const std::ostringstream& oss,
const ErrorObj& msg
153 #
if MESSAGEFACILITY_HEX_VERSION < 0x20002
154 , ELcontextSupplier
const&
158 const auto& xid = msg.xid();
159 auto message = oss.str();
161 # if MESSAGEFACILITY_HEX_VERSION >= 0x20002 // an indication of a switch from s48 to s50
162 auto level = xid.severity().getLevel();
164 auto level = xid.severity.getLevel();
170 # if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
171 case mf::ELseverityLevel::ELsev_incidental:
173 case mf::ELseverityLevel::ELsev_success:
174 case mf::ELseverityLevel::ELsev_zeroSeverity:
175 case mf::ELseverityLevel::ELsev_unspecified:
179 case mf::ELseverityLevel::ELsev_info:
183 case mf::ELseverityLevel::ELsev_warning:
184 # if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
185 case mf::ELseverityLevel::ELsev_warning2:
190 TRACE(lvlNum, message);
202 auto makePlugin(
const std::string&,
203 const fhicl::ParameterSet& pset)
205 return std::make_unique<mfplugins::ELTRACE>(pset);
209 DEFINE_BASIC_PLUGINTYPE_FUNC(mf::service::ELdestination)
Message Facility destination which logs messages to a TRACE buffer