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_writer.h b/aos/events/logging/log_writer.h
index 9f55edd..5c8b0c7 100644
--- a/aos/events/logging/log_writer.h
+++ b/aos/events/logging/log_writer.h
@@ -149,7 +149,8 @@
   // starts.
   void StartLoggingLocalNamerOnRun(std::string base_name) {
     event_loop_->OnRun([this, base_name]() {
-      StartLogging(std::make_unique<LocalLogNamer>(base_name, event_loop_));
+      StartLogging(
+          std::make_unique<LocalLogNamer>(base_name, event_loop_, node_));
     });
   }
 
@@ -157,7 +158,8 @@
   // processing starts.
   void StartLoggingOnRun(std::string base_name) {
     event_loop_->OnRun([this, base_name]() {
-      StartLogging(std::make_unique<MultiNodeLogNamer>(base_name, event_loop_));
+      StartLogging(std::make_unique<MultiNodeLogNamer>(
+          base_name, configuration_, event_loop_, node_));
     });
   }
 
@@ -236,6 +238,19 @@
   // The configuration to place at the top of the log file.
   const Configuration *const configuration_;
 
+  // The node that is writing the log.
+  // For most cases, this is the same node as the node that is reading the
+  // messages. However, in some cases, these two nodes may be different. i.e. if
+  // one node reading and modifying the messages, and another node is listening
+  // and saving those messages to another log.
+  //
+  // node_ is a pointer to the writing node, and that node is guaranteed to be
+  // in configuration_ which is the configuration being written to the top of
+  // the log file.
+  const Node *const node_;
+  // The node_index_ is the index of the node in configuration_.
+  const size_t node_index_;
+
   UUID log_event_uuid_ = UUID::Zero();
   const UUID logger_instance_uuid_ = UUID::Random();
   std::unique_ptr<LogNamer> log_namer_;