44// /
55
66#include " StdOut.h"
7-
8- #include < iostream>
97#include " ../MonLogger.h"
8+ #include < iostream>
109
1110namespace o2
1211{
@@ -24,7 +23,7 @@ inline unsigned long StdOut::convertTimestamp(const std::chrono::time_point<std:
2423 ).count ();
2524}
2625
27- StdOut::StdOut ()
26+ StdOut::StdOut () : mStream (std::cout)
2827{
2928 setVerbosisty (backend::Verbosity::Debug);
3029 MonLogger::Get () << " StdOut backend initialized" << MonLogger::End ();
@@ -57,9 +56,11 @@ void StdOut::sendMultiple(std::string measurement, std::vector<Metric>&& metrics
5756 if (!metricTags.empty ()) {
5857 metricTags = " ," + metricTags;
5958 }
60- MonLogger::Get () << " [METRIC] " << measurement << " /" << metric.getName () << " ," << metric.getType () << " "
61- << metric.getValue () << " " << convertTimestamp (metric.getTimestamp ()) << " " << tagString << metricTags
62- << MonLogger::End ();
59+ auto tStamp = std::chrono::system_clock::to_time_t (metric.getTimestamp ());
60+ mStream << std::put_time (std::localtime (&tStamp), " %Y-%m-%d %X" ) << " \t "
61+ << " [METRIC] " << measurement << " /" << metric.getName () << " ," << metric.getType () << " "
62+ << metric.getValue () << " " << convertTimestamp (metric.getTimestamp ()) << " " << tagString
63+ << metricTags << " \n " ;
6364 }
6465}
6566
@@ -75,9 +76,11 @@ void StdOut::send(const Metric& metric)
7576 if (!metricTags.empty ()) {
7677 metricTags = " ," + metricTags;
7778 }
78- MonLogger::Get () << " [METRIC] " << metric.getName () << " ," << metric.getType () << " " << metric.getValue ()
79+ auto tStamp = std::chrono::system_clock::to_time_t (metric.getTimestamp ());
80+ mStream << std::put_time (std::localtime (&tStamp), " %Y-%m-%d %X" ) << " \t "
81+ << " [METRIC] " << metric.getName () << " ," << metric.getType () << " " << metric.getValue ()
7982 << " " << convertTimestamp (metric.getTimestamp ()) << " " << tagString << metricTags
80- << MonLogger::End () ;
83+ << " \n " ;
8184}
8285
8386} // namespace backends
0 commit comments