sanify logging during startup
diff --git a/aos/common/logging/logging_impl.cc b/aos/common/logging/logging_impl.cc
index 8aa66f5..43a20e0 100644
--- a/aos/common/logging/logging_impl.cc
+++ b/aos/common/logging/logging_impl.cc
@@ -20,6 +20,10 @@
// apply here (mostly the parts about being able to use LOG) because this is the
// root one.
class RootLogImplementation : public LogImplementation {
+ public:
+ void have_other_implementation() { only_implementation_ = false; }
+
+ private:
virtual void set_next(LogImplementation *) {
LOG(FATAL, "can't have a next logger from here\n");
}
@@ -29,10 +33,16 @@
LogMessage message;
internal::FillInMessage(level, format, ap, &message);
internal::PrintMessage(stderr, message);
- fputs("root logger got used, see stderr for message\n", stdout);
+ if (!only_implementation_) {
+ fputs("root logger got used, see stderr for message\n", stdout);
+ }
}
+
+ bool only_implementation_ = true;
};
+RootLogImplementation *root_implementation = nullptr;
+
void SetGlobalImplementation(LogImplementation *implementation) {
Context *context = Context::Get();
@@ -45,7 +55,7 @@
}
void *DoInit() {
- SetGlobalImplementation(new RootLogImplementation());
+ SetGlobalImplementation(root_implementation = new RootLogImplementation());
if (pthread_atfork(NULL /*prepare*/, NULL /*parent*/,
NewContext /*child*/) != 0) {
@@ -295,6 +305,7 @@
implementation->set_next(old);
}
SetGlobalImplementation(implementation);
+ root_implementation->have_other_implementation();
}
void Init() {