Add statistics for how far behind the logger falls

This patch adds a new couple of fields to the logger status message to
show how far behind we are in logging.

I added a new unit test to validate that the fields are set.

Change-Id: I41675096056992bcafa3db24d094c4f78379be86
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/logging/log_writer.cc b/aos/events/logging/log_writer.cc
index 69b0542..e8b8819 100644
--- a/aos/events/logging/log_writer.cc
+++ b/aos/events/logging/log_writer.cc
@@ -684,6 +684,8 @@
   total_copy_time_ = std::chrono::nanoseconds::zero();
   total_copy_count_ = 0;
   total_copy_bytes_ = 0;
+  max_log_delay_ = std::chrono::nanoseconds::zero();
+  max_log_delay_channel_ = -1;
 }
 
 void Logger::Rotate() {
@@ -912,6 +914,11 @@
     max_copy_time_channel_ = fetcher.channel_index;
     max_copy_time_size_ = fetcher.fetcher->context().size;
   }
+  const auto log_delay = end - fetcher.fetcher->context().monotonic_event_time;
+  if (log_delay > max_log_delay_) {
+    max_log_delay_ = log_delay;
+    max_log_delay_channel_ = fetcher.channel_index;
+  }
 }
 
 }  // namespace logger