8#include <framework/pcore/zmq/utils/ZMQLogger.h>
9#include <boost/property_tree/json_parser.hpp>
17 std::stringstream buffer;
25 buffer <<
"\"" << keyValue.first <<
"\": ";
26 buffer << std::visit(
toJSON{}, keyValue.second);
28 buffer <<
"}" << std::endl;
44 auto current = std::chrono::system_clock::now();
45 auto displayTime = std::chrono::system_clock::to_time_t(current);
46 log(key, std::ctime(&displayTime));
51 return std::to_string(value);
56 return std::to_string(value);
61 return "\"" + boost::property_tree::json_parser::create_escapes(value) +
"\"";
76 throw std::domain_error(
"Can not increment a string type");
91 throw std::domain_error(
"Can not decrement a string type");
void decrement(const std::string &key)
Decrement the value with the given key (only numerical values). If not present, set to -1.
virtual std::string getMonitoringJSON() const
Convert the stored monitoring values to a JSON string ready for sending out via a message.
void logTime(const std::string &key)
Store the current time as a string under the given key.
void increment(const std::string &key)
Increment the value with the given key (only numerical values). If not present, set to 1.
std::map< std::string, std::variant< long, double, std::string > > m_monitoring
Internal storage of all stored values.
void log(const std::string &key, const AClass &value)
Store a value under a certain key. Different types of values can be stored, namely long,...
Abstract base class for different kinds of events.
Visitor Helper for decrementing a numerical value.
void operator()(long &value)
-1 for longs
Visitor Helper for incrementing a numerical value.
void operator()(long &value)
+1 for longs
Visitor Helper for converting a variant value into a JSON string.
std::string operator()(long value)
just stringify longs