Untangle and clean up the logging code

It was a mess before because of a combination of having code split out
for cRIO vs Linux and cruft.

Change-Id: Id282e1a7f7988be0441c669a573a5d022ed41fb9
diff --git a/aos/common/logging/queue_logging.h b/aos/common/logging/queue_logging.h
index ff0167a..888f808 100644
--- a/aos/common/logging/queue_logging.h
+++ b/aos/common/logging/queue_logging.h
@@ -4,9 +4,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <functional>
 #include <string>
 
-#include "aos/common/logging/logging.h"
+#include "aos/common/logging/interface.h"
 #include "aos/common/die.h"
 
 namespace aos {
@@ -14,24 +15,29 @@
 
 // Logs the contents of a structure (or Queue message) and a constant string.
 // structure must be an instance of one of the generated queue types.
-#define LOG_STRUCT(level, message, structure)                          \
-  do {                                                                 \
-    static const ::std::string kAosLoggingMessage(                     \
-        LOG_SOURCENAME ": " STRINGIFY(__LINE__) ": " message);         \
-    ::aos::logging::DoLogStruct(level, kAosLoggingMessage, structure); \
-    /* so that GCC knows that it won't return */                       \
-    if (level == FATAL) {                                              \
-      ::aos::Die("DoLogStruct(FATAL) fell through!!!!!\n");            \
-    }                                                                  \
+#define LOG_STRUCT(level, message, structure)                       \
+  do {                                                              \
+    static const ::std::string kAosLoggingMessage(                  \
+        LOG_SOURCENAME ": " STRINGIFY(__LINE__) ": " message);      \
+    ::aos::logging::DoLogStructTemplated(level, kAosLoggingMessage, \
+                                         structure);                \
+    /* so that GCC knows that it won't return */                    \
+    if (level == FATAL) {                                           \
+      ::aos::Die("DoLogStruct(FATAL) fell through!!!!!\n");         \
+    }                                                               \
   } while (false)
 
 template <class T>
-void DoLogStruct(log_level level, const ::std::string &message,
-                 const T &structure);
+void DoLogStructTemplated(log_level level, const ::std::string &message,
+                          const T &structure) {
+  auto fn = [&structure](char *buffer)
+                -> size_t { return structure.Serialize(buffer); };
+
+  internal::DoLogStruct(level, message, T::Size(), T::GetType(), ::std::ref(fn),
+                        1);
+}
 
 }  // namespace logging
 }  // namespace aos
 
-#include "aos/common/logging/queue_logging-tmpl.h"
-
 #endif  // AOS_COMMON_LOGGING_QUEUE_LOGGING_H_