7 #include "artdaq-utilities/Plugins/MetricMacros.hh"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "messagefacility/MessageLogger/MessageLogger.h"
23 std::string facility_;
40 , facility_(config.get<std::string>(
"output_message_category_name",
"ARTDAQ Metric"))
45 outputLevel_ = config.get<
int>(
"output_message_severity", 0);
47 catch (cet::exception)
49 std::string levelString = config.get<std::string>(
"output_message_severity",
"Info");
50 if (levelString ==
"Info" || levelString ==
"info" || levelString ==
"LogInfo")
54 else if (levelString ==
"Debug" || levelString ==
"debug" || levelString ==
"LogDebug")
58 else if (levelString ==
"Warning" || levelString ==
"warning" || levelString ==
"LogWarning" || levelString ==
"Warn" || levelString ==
"warn")
62 else if (levelString ==
"Error" || levelString ==
"error" || levelString ==
"LogError")
78 std::string
getLibName()
const override {
return "msgFacility"; }
86 void sendMetric_(
const std::string& name,
const std::string& value,
const std::string& unit)
override
93 mf::LogInfo(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
96 mf::LogDebug(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
99 mf::LogWarning(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
102 mf::LogError(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
114 void sendMetric_(
const std::string& name,
const int& value,
const std::string& unit)
override
125 void sendMetric_(
const std::string& name,
const double& value,
const std::string& unit)
override
136 void sendMetric_(
const std::string& name,
const float& value,
const std::string& unit)
override
147 void sendMetric_(
const std::string& name,
const unsigned long int& value,
const std::string& unit)
override
The MetricPlugin class defines the interface that MetricManager uses to send metric data to the vario...
void startMetrics()
Perform startup actions. Simply calls the virtual startMetrics_ function.
void sendMetric_(const std::string &name, const int &value, const std::string &unit) override
Send a metric to MessageFacility. All metrics are converted to strings.
std::string getLibName() const override
Return the library name of the MetricPlugin.
void sendMetric_(const std::string &name, const float &value, const std::string &unit) override
Send a metric to MessageFacility. All metrics are converted to strings.
void stopMetrics()
Perform shutdown actions. Zeroes out all accumulators, and sends zeros for each metric. Calls stopMetrics_() for any plugin-defined shutdown actions.
void stopMetrics_() override
Perform shutdown actions. No-Op.
void sendMetric_(const std::string &name, const std::string &value, const std::string &unit) override
Send a metric to MessageFacilty. Format is: "name: value unit.".
void startMetrics_() override
Perform startup actions. No-Op.
virtual ~MsgFacilityMetric()
MsgFacilityMetric Destructor. Calls stopMetrics()
MsgFacilityMetric(fhicl::ParameterSet config)
MsgFacilityMetric Constructor.
A MetricPlugin class which sends metric data to MessageFacility.
void sendMetric_(const std::string &name, const unsigned long int &value, const std::string &unit) override
Send a metric to MessageFacility. All metrics are converted to strings.
void sendMetric_(const std::string &name, const double &value, const std::string &unit) override
Send a metric to MessageFacility. All metrics are converted to strings.
bool inhibit_
Whether to inhibit all metric sending.