7 #include "artdaq-utilities/Plugins/MetricMacros.hh"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "messagefacility/MessageLogger/MessageLogger.h"
22 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 (
const 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
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 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_
Flag to indicate that the MetricPlugin is being stopped, and any metric back-ends which do not have a...