Remove multiple logging implementations.
Change-Id: I7474c29b394f37918a35bba58b2fab58a7be930f
diff --git a/aos/logging/interface.cc b/aos/logging/interface.cc
index b72f8e1..e6e9203 100644
--- a/aos/logging/interface.cc
+++ b/aos/logging/interface.cc
@@ -4,8 +4,8 @@
#include <stdio.h>
#include <string.h>
-#include <type_traits>
#include <functional>
+#include <type_traits>
#include "aos/die.h"
#include "aos/logging/context.h"
@@ -21,8 +21,8 @@
const int ret = vsnprintf(output, size, format, ap);
typedef ::std::common_type<int, size_t>::type RetType;
if (ret < 0) {
- AOS_PLOG(FATAL, "vsnprintf(%p, %zd, %s, args) failed",
- output, size, format);
+ AOS_PLOG(FATAL, "vsnprintf(%p, %zd, %s, args) failed", output, size,
+ format);
} else if (static_cast<RetType>(ret) >= static_cast<RetType>(size)) {
// Overwrite the '\0' at the end of the existing data and
// copy in the one on the end of continued.
@@ -32,30 +32,22 @@
}
void RunWithCurrentImplementation(
- int levels, ::std::function<void(LogImplementation *)> function) {
+ ::std::function<void(LogImplementation *)> function) {
Context *context = Context::Get();
- LogImplementation *const top_implementation = context->implementation;
- LogImplementation *new_implementation = top_implementation;
- LogImplementation *implementation = NULL;
- for (int i = 0; i < levels; ++i) {
- implementation = new_implementation;
- if (new_implementation == NULL) {
- Die("no logging implementation to use\n");
- }
- new_implementation = new_implementation->next();
+ LogImplementation *const implementation = context->implementation;
+ if (implementation == NULL) {
+ Die("no logging implementation to use\n");
}
- context->implementation = new_implementation;
function(implementation);
- context->implementation = top_implementation;
}
} // namespace internal
using internal::Context;
-void LogImplementation::DoVLog(log_level level, const char *format, va_list ap,
- int levels) {
+void LogImplementation::DoVLog(log_level level, const char *format,
+ va_list ap) {
auto log_impl = [&](LogImplementation *implementation) {
va_list ap1;
va_copy(ap1, ap);
@@ -66,11 +58,11 @@
VDie(format, ap);
}
};
- internal::RunWithCurrentImplementation(levels, ::std::ref(log_impl));
+ internal::RunWithCurrentImplementation(::std::ref(log_impl));
}
void VLog(log_level level, const char *format, va_list ap) {
- LogImplementation::DoVLog(level, format, ap, 1);
+ LogImplementation::DoVLog(level, format, ap);
}
void VCork(int line, const char *function, const char *format, va_list ap) {
@@ -101,9 +93,8 @@
VCork(line, function, format, ap);
- log_do(level, "%s: %d-%d: %s: %s", file,
- context->cork_data.line_min, context->cork_data.line_max, function,
- context->cork_data.message);
+ log_do(level, "%s: %d-%d: %s: %s", file, context->cork_data.line_min,
+ context->cork_data.line_max, function, context->cork_data.message);
context->cork_data.Reset();
}