AOS was not writing timestamp data header
AOS wasn't writing out the header to the timestamp data log part. Which
means the log part is corrupted and can't be read. Let's fix the bug
that's causing that, and put some checks in so if a log doesn't have a
header if throws a more helpful error than a segfault.
This was only happening when trying to relog a logfile with a
pre-existing config.
Change-Id: I373821f4cfbead90daddd820d3c61693e8886eda
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/events/logging/log_namer.h b/aos/events/logging/log_namer.h
index 8a44c97..c2c8dd1 100644
--- a/aos/events/logging/log_namer.h
+++ b/aos/events/logging/log_namer.h
@@ -114,10 +114,11 @@
public:
// Constructs a LogNamer with the primary node (ie the one the logger runs on)
// being node.
- LogNamer(EventLoop *event_loop)
+ LogNamer(const aos::Configuration *configuration, EventLoop *event_loop,
+ const aos::Node *node)
: event_loop_(event_loop),
- configuration_(event_loop_->configuration()),
- node_(event_loop_->node()),
+ configuration_(configuration),
+ node_(node),
logger_node_index_(configuration::GetNodeIndex(configuration_, node_)) {
nodes_.emplace_back(node_);
node_states_.resize(configuration::NodesCount(configuration_));
@@ -241,10 +242,11 @@
// any other log type.
class LocalLogNamer : public LogNamer {
public:
- LocalLogNamer(std::string_view base_name, aos::EventLoop *event_loop)
- : LogNamer(event_loop),
+ LocalLogNamer(std::string_view base_name, aos::EventLoop *event_loop,
+ const aos::Node *node)
+ : LogNamer(event_loop->configuration(), event_loop, node),
base_name_(base_name),
- data_writer_(this, node(),
+ data_writer_(this, node,
[this](NewDataWriter *writer) {
writer->writer = std::make_unique<DetachedBufferWriter>(
absl::StrCat(base_name_, ".part",
@@ -289,6 +291,9 @@
class MultiNodeLogNamer : public LogNamer {
public:
MultiNodeLogNamer(std::string_view base_name, EventLoop *event_loop);
+ MultiNodeLogNamer(std::string_view base_name,
+ const Configuration *configuration, EventLoop *event_loop,
+ const Node *node);
~MultiNodeLogNamer() override;
std::string_view base_name() const final { return base_name_; }