-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "software/logger/network_logger.h" | ||
|
||
#include "software/logger/csv_sink.h" | ||
#include "software/logger/plotjuggler_sink.h" | ||
|
||
std::shared_ptr<NetworkLoggerSingleton> NetworkLoggerSingleton::instance; | ||
|
||
NetworkLoggerSingleton::NetworkLoggerSingleton(int robot_id, bool enable_log_merging) | ||
{ | ||
logWorker = g3::LogWorker::createLogWorker(); | ||
|
||
network_sink_handle = logWorker->addSink(std::make_unique<NetworkSink>(robot_id, enable_log_merging), | ||
&NetworkSink::sendToNetwork); | ||
|
||
// Sink for outputting logs to the terminal | ||
auto colour_cout_sink_handle = | ||
logWorker->addSink(std::make_unique<ColouredCoutSink>(true), | ||
&ColouredCoutSink::displayColouredLog); | ||
|
||
auto csv_sink_handle = logWorker->addSink(std::make_unique<CSVSink>(CSV_PATH), | ||
&CSVSink::appendToFile); | ||
|
||
// Sink for PlotJuggler plotting | ||
auto plotjuggler_handle = logWorker->addSink(std::make_unique<PlotJugglerSink>(), | ||
&PlotJugglerSink::sendToPlotJuggler); | ||
|
||
g3::initializeLogging(logWorker.get()); | ||
} | ||
|
||
void NetworkLoggerSingleton::initializeLogger(int robot_id, bool enable_log_merging) | ||
{ | ||
if (!instance) | ||
{ | ||
instance = std::make_shared<NetworkLoggerSingleton>(robot_id, enable_log_merging); | ||
} | ||
} | ||
|
||
void NetworkLoggerSingleton::replaceUdpSender(std::shared_ptr<ThreadedProtoUdpSender<TbotsProto::RobotLog>> new_sender) | ||
{ | ||
if (!instance) | ||
{ | ||
return; | ||
} | ||
instance->network_sink_handle->call(&NetworkSink::replaceUdpSender, new_sender); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters