Actually manage memory in the old-style AOS logging

LeakSanitizer should be happy with it now. It's also still just as
thread-safe.

Change-Id: Id09a0349657cf4f719267b053f0ea3d8ec366256
diff --git a/aos/logging/context.h b/aos/logging/context.h
index b2abc0d..2e8250e 100644
--- a/aos/logging/context.h
+++ b/aos/logging/context.h
@@ -2,9 +2,10 @@
 #define AOS_LOGGING_CONTEXT_H_
 
 #include <inttypes.h>
+#include <limits.h>
 #include <stddef.h>
 #include <sys/types.h>
-#include <limits.h>
+#include <memory>
 
 #include <atomic>
 
@@ -19,8 +20,6 @@
 // goes.
 namespace internal {
 
-extern ::std::atomic<LogImplementation *> global_top_implementation;
-
 // An separate instance of this class is accessible from each task/thread.
 // NOTE: It will get deleted in the child of a fork.
 //
@@ -43,9 +42,11 @@
   // still work to clean up any state.
   static void Delete();
 
+  static void DeleteNow();
+
   // Which one to log to right now.
   // Will be NULL if there is no logging implementation to use right now.
-  LogImplementation *implementation;
+  std::shared_ptr<LogImplementation> implementation;
 
   // A name representing this task/(process and thread).
   char name[LOG_MESSAGE_NAME_LEN];