7 #include "artdaq-utilities/Plugins/MetricMacros.hh"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "messagefacility/MessageLogger/MessageLogger.h"
23 std::string facility_;
41 , facility_(config.get<std::string>(
"output_message_category_name",
"ARTDAQ Metric"))
46 outputLevel_ = config.get<
int>(
"output_message_severity", 0);
48 catch (cet::exception)
50 std::string levelString = config.get<std::string>(
"output_message_severity",
"Info");
51 if (levelString ==
"Info" || levelString ==
"info" || levelString ==
"LogInfo")
55 else if (levelString ==
"Debug" || levelString ==
"debug" || levelString ==
"LogDebug")
59 else if (levelString ==
"Warning" || levelString ==
"warning" || levelString ==
"LogWarning" || levelString ==
"Warn" || levelString ==
"warn")
63 else if (levelString ==
"Error" || levelString ==
"error" || levelString ==
"LogError")
79 std::string
getLibName()
const override {
return "msgFacility"; }
87 void sendMetric_(
const std::string& name,
const std::string& value,
const std::string& unit)
override
94 mf::LogInfo(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
97 mf::LogDebug(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
100 mf::LogWarning(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
103 mf::LogError(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
115 void sendMetric_(
const std::string& name,
const int& value,
const std::string& unit)
override
126 void sendMetric_(
const std::string& name,
const double& value,
const std::string& unit)
override
137 void sendMetric_(
const std::string& name,
const float& value,
const std::string& unit)
override
148 void sendMetric_(
const std::string& name,
const unsigned long int& value,
const std::string& unit)
override
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_() 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 const &config, std::string const &app_name)
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.