7 #include "artdaq-utilities/Plugins/MetricMacros.hh"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "messagefacility/MessageLogger/MessageLogger.h"
20 std::string facility_;
25 , facility_(config.get<std::string>(
"output_message_application_name",
"ARTDAQ Metric"))
30 outputLevel_ = config.get<
int>(
"output_message_severity", 0);
32 catch (cet::exception)
34 std::string levelString = config.get<std::string>(
"output_message_severity",
"Info");
35 if (levelString ==
"Info" || levelString ==
"info" || levelString ==
"LogInfo")
39 else if (levelString ==
"Debug" || levelString ==
"debug" || levelString ==
"LogDebug")
43 else if (levelString ==
"Warning" || levelString ==
"warning" || levelString ==
"LogWarning" || levelString ==
"Warn" || levelString ==
"warn")
47 else if (levelString ==
"Error" || levelString ==
"error" || levelString ==
"LogError")
56 virtual std::string getLibName()
const {
return "msgFacility"; }
58 virtual void sendMetric_(
const std::string& name,
const std::string& value,
const std::string& unit)
65 mf::LogInfo(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
68 mf::LogDebug(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
71 mf::LogWarning(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
74 mf::LogError(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
80 virtual void sendMetric_(
const std::string& name,
const int& value,
const std::string& unit)
82 sendMetric(name, std::to_string(value), unit);
85 virtual void sendMetric_(
const std::string& name,
const double& value,
const std::string& unit)
87 sendMetric(name, std::to_string(value), unit);
90 virtual void sendMetric_(
const std::string& name,
const float& value,
const std::string& unit)
92 sendMetric(name, std::to_string(value), unit);
95 virtual void sendMetric_(
const std::string& name,
const unsigned long int& value,
const std::string& unit)
97 sendMetric(name, std::to_string(value), unit);
100 virtual void startMetrics_() {}
101 virtual void stopMetrics_() {}