3#include <google/protobuf/message.h>
9#include "software/multithreading/thread_safe_buffer.hpp"
39 struct SerializedProtoLog
41 std::string protobuf_type_full_name;
42 std::string serialized_proto;
43 double receive_time_sec;
54 std::function<
double()> time_provider,
55 bool friendly_colour_yellow);
75 const std::string& serialized_proto);
84 template <
typename ProtoType>
87 static_assert(std::is_base_of<google::protobuf::Message, ProtoType>::value,
88 "ProtoType has to be a protobuf message type");
117 static std::string
createLogEntry(
const std::string& proto_full_name,
118 const std::string& serialized_proto,
119 double receive_time_sec);
131 bool shouldStopLogging()
const;
133 std::string log_path_;
134 std::string log_folder_;
135 std::function<double()> time_provider_;
137 bool friendly_colour_yellow_;
138 unsigned int failed_logs_frequency_counter_ = 0;
140 std::thread log_thread_;
141 std::atomic<bool> stop_logging_;
142 double destructor_called_time_sec_;
147 const std::string REPLAY_FILE_PREFIX =
"proto_";
148 const std::string REPLAY_FILE_TIME_FORMAT =
"%Y_%m_%d_%H_%M_%S";
149 static constexpr unsigned int PROTOBUF_BUFFER_SIZE = 1000;
150 static constexpr unsigned int REPLAY_MAX_CHUNK_SIZE_BYTES = 1024 * 1024;
151 static constexpr unsigned int FAILED_LOG_PRINT_FREQUENCY = 100;
static const Duration fromSeconds(double seconds)
Definition duration.cpp:13
Definition proto_logger.h:35
void saveSerializedProto(const std::string &serialized_proto)
Definition proto_logger.h:85
ProtoLogger(const ProtoLogger &)=delete
void saveSerializedProto(const std::string &protobuf_type_full_name, const std::string &serialized_proto)
Definition proto_logger.cpp:45
void flushAndStopLogging()
Definition proto_logger.cpp:170
void updateTimeProvider(std::function< double()> time_provider)
Definition proto_logger.cpp:149
static std::string createLogEntry(const std::string &proto_full_name, const std::string &serialized_proto, double receive_time_sec)
Definition proto_logger.cpp:138
Definition thread_safe_buffer.hpp:23