Make AOS logging per thread, not global
We noticed that if 2 threads use AOS_LOG, they occasionally crash. The
stack trace looked like 2 messages were being constructed
simultaneously. Digging in, this is possible because there is 1 global
logger which gets passed (patchily) to the per-thread context.
We've got a bunch of different cases and (reasonable) ways to handle
them when ShmEventLoop comes into play.
Simple single threaded appliction:
* Outside Run() -> stderr
* Inside Run() -> /aos
Single event loop appliction with extra threads
* Outside Run() -> stderr
* Inside Run() -> /aos
* Other threads -> stderr
Multiple event loop appliction with extra threads
* Outside Run() -> stderr
* Inside Run() -> /aos
* Other threads -> stderr
Simulation:
* Inside Run -> /aos
* Outside Run -> stderr
This pretty quickly quickly looks like a thread local logging handler
and a fallback to stderr. We don't really need much more, and don't
want to worry about synchronization for much more, so lets just do the
simple thing for now and revise if there are better use cases.
Change-Id: I90d76516a55f0b01a8a0e27ad0434dac5921e261
diff --git a/aos/dump_rtprio.cc b/aos/dump_rtprio.cc
index 5f4397f..006b348 100644
--- a/aos/dump_rtprio.cc
+++ b/aos/dump_rtprio.cc
@@ -247,8 +247,6 @@
} // namespace
int main() {
- ::aos::logging::Init();
-
const int pid_max = find_pid_max();
const cpu_set_t all_cpus = find_all_cpus();
diff --git a/aos/events/event_loop.cc b/aos/events/event_loop.cc
index 639e337..5c0b628 100644
--- a/aos/events/event_loop.cc
+++ b/aos/events/event_loop.cc
@@ -81,9 +81,7 @@
EventLoop::EventLoop(const Configuration *configuration)
: timing_report_(flatbuffers::DetachedBuffer()),
- configuration_(configuration) {
- logging::Init();
-}
+ configuration_(configuration) {}
EventLoop::~EventLoop() {
CHECK_EQ(senders_.size(), 0u) << ": Not all senders destroyed";
diff --git a/aos/init.cc b/aos/init.cc
index 163f5dd..51e22cf 100644
--- a/aos/init.cc
+++ b/aos/init.cc
@@ -39,7 +39,6 @@
// Common stuff that needs to happen at the beginning of both the realtime and
// non-realtime initialization sequences. May be called twice.
void InitStart() {
- ::aos::logging::Init();
if (FLAGS_coredump) {
WriteCoreDumps();
}
diff --git a/aos/ipc_lib/eventfd_latency.cc b/aos/ipc_lib/eventfd_latency.cc
index 9229f1a..d146c13 100644
--- a/aos/ipc_lib/eventfd_latency.cc
+++ b/aos/ipc_lib/eventfd_latency.cc
@@ -160,7 +160,5 @@
int main(int argc, char **argv) {
::gflags::ParseCommandLineFlags(&argc, &argv, true);
- ::aos::logging::Init();
-
return ::aos::Main(argc, argv);
}
diff --git a/aos/ipc_lib/futex_latency.cc b/aos/ipc_lib/futex_latency.cc
index 59fa860..ef27e29 100644
--- a/aos/ipc_lib/futex_latency.cc
+++ b/aos/ipc_lib/futex_latency.cc
@@ -164,7 +164,5 @@
int main(int argc, char **argv) {
::gflags::ParseCommandLineFlags(&argc, &argv, true);
- ::aos::logging::Init();
-
return ::aos::Main(argc, argv);
}
diff --git a/aos/ipc_lib/ipc_comparison.cc b/aos/ipc_lib/ipc_comparison.cc
index 9191eae..6435ee7 100644
--- a/aos/ipc_lib/ipc_comparison.cc
+++ b/aos/ipc_lib/ipc_comparison.cc
@@ -902,7 +902,6 @@
::gflags::ParseCommandLineFlags(&argc, &argv, true);
::aos::InitNRT();
- ::aos::logging::Init();
return ::aos::Main(argc, argv);
}
diff --git a/aos/ipc_lib/named_pipe_latency.cc b/aos/ipc_lib/named_pipe_latency.cc
index c3f5c5c..2bd24f3 100644
--- a/aos/ipc_lib/named_pipe_latency.cc
+++ b/aos/ipc_lib/named_pipe_latency.cc
@@ -168,7 +168,5 @@
int main(int argc, char **argv) {
::gflags::ParseCommandLineFlags(&argc, &argv, true);
- ::aos::logging::Init();
-
return ::aos::Main(argc, argv);
}
diff --git a/aos/ipc_lib/signal_stress.cc b/aos/ipc_lib/signal_stress.cc
index ea9537f..60243fd 100644
--- a/aos/ipc_lib/signal_stress.cc
+++ b/aos/ipc_lib/signal_stress.cc
@@ -191,7 +191,5 @@
int main(int argc, char **argv) {
::gflags::ParseCommandLineFlags(&argc, &argv, true);
- ::aos::logging::Init();
-
return ::aos::Main(argc, argv);
}
diff --git a/aos/logging/context.cc b/aos/logging/context.cc
index 446e0df..0628e0e 100644
--- a/aos/logging/context.cc
+++ b/aos/logging/context.cc
@@ -42,7 +42,7 @@
char thread_name_array[kThreadNameLength + 1];
if (prctl(PR_GET_NAME, thread_name_array) != 0) {
- PDie("prctl(PR_GET_NAME, %p) failed", thread_name_array);
+ PLOG(FATAL) << "prctl(PR_GET_NAME, " << thread_name_array << ") failed";
}
#if __has_feature(memory_sanitizer)
// msan doesn't understand PR_GET_NAME, so help it along.
@@ -73,7 +73,7 @@
} // namespace
-Context::Context() : implementation(GetImplementation()), sequence(0) {}
+Context::Context() : sequence(0) {}
// Used in aos/linux_code/init.cc when a thread's name is changed.
void ReloadThreadName() {
diff --git a/aos/logging/context.h b/aos/logging/context.h
index 43ac54f..cc770ba 100644
--- a/aos/logging/context.h
+++ b/aos/logging/context.h
@@ -45,7 +45,8 @@
static void DeleteNow();
// Which one to log to right now.
- // Will be NULL if there is no logging implementation to use right now.
+ // Will be NULL if there is no logging implementation to use right now and we
+ // should use stderr instead.
std::shared_ptr<LogImplementation> implementation;
// A name representing this task/(process and thread).
diff --git a/aos/logging/implementations.cc b/aos/logging/implementations.cc
index 096127a..be54eec 100644
--- a/aos/logging/implementations.cc
+++ b/aos/logging/implementations.cc
@@ -5,33 +5,17 @@
#include <algorithm>
#include <chrono>
-#include <mutex>
-#include "absl/base/call_once.h"
-#include "aos/die.h"
#include "aos/logging/printf_formats.h"
-#include "aos/stl_mutex/stl_mutex.h"
#include "aos/time/time.h"
namespace aos {
namespace logging {
+namespace internal {
namespace {
namespace chrono = ::std::chrono;
-struct GlobalState {
- std::shared_ptr<LogImplementation> implementation;
- aos::stl_mutex lock;
- static GlobalState *Get() {
- static GlobalState r;
- return &r;
- }
-};
-
-} // namespace
-namespace internal {
-namespace {
-
void FillInMessageBase(log_level level,
monotonic_clock::time_point monotonic_now,
LogMessage *message) {
@@ -61,21 +45,15 @@
message->message_length =
ExecuteFormat(message->message, sizeof(message->message), format, ap);
- message->type = LogMessage::Type::kString;
}
void PrintMessage(FILE *output, const LogMessage &message) {
-#define BASE_ARGS \
- AOS_LOGGING_BASE_ARGS( \
- message.name_length, message.name, static_cast<int32_t>(message.source), \
- message.sequence, message.level, message.seconds, message.nseconds)
- switch (message.type) {
- case LogMessage::Type::kString:
- fprintf(output, AOS_LOGGING_BASE_FORMAT "%.*s", BASE_ARGS,
- static_cast<int>(message.message_length), message.message);
- break;
- }
-#undef BASE_ARGS
+ fprintf(output, AOS_LOGGING_BASE_FORMAT "%.*s",
+ AOS_LOGGING_BASE_ARGS(message.name_length, message.name,
+ static_cast<int32_t>(message.source),
+ message.sequence, message.level,
+ message.seconds, message.nseconds),
+ static_cast<int>(message.message_length), message.message);
}
} // namespace internal
@@ -95,55 +73,13 @@
}
void SetImplementation(std::shared_ptr<LogImplementation> implementation) {
- Init();
- GlobalState *const global = GlobalState::Get();
- std::unique_lock<aos::stl_mutex> locker(global->lock);
- global->implementation = std::move(implementation);
-}
-
-std::shared_ptr<LogImplementation> SwapImplementation(
- std::shared_ptr<LogImplementation> implementation) {
- std::shared_ptr<LogImplementation> result;
- {
- GlobalState *const global = GlobalState::Get();
- std::unique_lock<aos::stl_mutex> locker(global->lock);
- result = std::move(global->implementation);
- global->implementation = std::move(implementation);
- }
- Cleanup();
- return result;
+ internal::Context *context = internal::Context::Get();
+ context->implementation = std::move(implementation);
}
std::shared_ptr<LogImplementation> GetImplementation() {
- GlobalState *const global = GlobalState::Get();
- std::unique_lock<aos::stl_mutex> locker(global->lock);
- CHECK(global->implementation);
- return global->implementation;
-}
-
-namespace {
-
-struct DoInit {
- DoInit() {
- GlobalState *const global = GlobalState::Get();
- std::unique_lock<aos::stl_mutex> locker(global->lock);
- CHECK(!global->implementation);
- global->implementation = std::make_shared<StreamLogImplementation>(stdout);
- }
-};
-
-} // namespace
-
-void Init() { static DoInit do_init; }
-
-void Load() { internal::Context::Get(); }
-
-void Cleanup() { internal::Context::Delete(); }
-
-void RegisterCallbackImplementation(
- const ::std::function<void(const LogMessage &)> &callback) {
- Init();
- SetImplementation(std::make_shared<CallbackLogImplementation>(callback));
+ internal::Context *context = internal::Context::Get();
+ return context->implementation;
}
} // namespace logging
diff --git a/aos/logging/implementations.h b/aos/logging/implementations.h
index 962982b..6395c37 100644
--- a/aos/logging/implementations.h
+++ b/aos/logging/implementations.h
@@ -35,8 +35,6 @@
// Contains all of the information about a given logging call.
struct LogMessage {
- enum class Type : uint8_t { kString };
-
int32_t seconds, nseconds;
// message_length is just the length of the actual data (which member depends
// on the type).
@@ -45,26 +43,9 @@
static_assert(sizeof(source) == 4, "that's how they get printed");
// Per task/thread.
uint16_t sequence;
- Type type;
log_level level;
char name[LOG_MESSAGE_NAME_LEN];
- union {
- char message[LOG_MESSAGE_LEN];
- struct {
- uint32_t type_id;
- size_t string_length;
- // The message string and then the serialized structure.
- char serialized[LOG_MESSAGE_LEN - sizeof(type) - sizeof(string_length)];
- } structure;
- struct {
- // The type ID of the element type.
- uint32_t type;
- int rows, cols;
- size_t string_length;
- // The message string and then the serialized matrix.
- char data[LOG_MESSAGE_LEN - sizeof(type) - sizeof(rows) - sizeof(cols)];
- } matrix;
- };
+ char message[LOG_MESSAGE_LEN];
};
static_assert(shm_ok<LogMessage>::value, "it's going in a queue");
@@ -118,20 +99,13 @@
FILE *const stream_;
};
+// Returns the current implementation.
std::shared_ptr<LogImplementation> GetImplementation();
// Sets the current implementation.
void SetImplementation(std::shared_ptr<LogImplementation> implementation);
-// Updates the log implementation, returning the current implementation.
-std::shared_ptr<LogImplementation> SwapImplementation(
- std::shared_ptr<LogImplementation> implementation);
-
-// Must be called at least once per process/load before anything else is
-// called. This function is safe to call multiple times from multiple
-// tasks/threads.
-void Init();
-
+// A logging implementation which just uses a callback.
class CallbackLogImplementation : public HandleMessageLogImplementation {
public:
CallbackLogImplementation(
@@ -144,27 +118,13 @@
::std::function<void(const LogMessage &)> callback_;
};
-// Resets all information in this task/thread to its initial state.
-// NOTE: This is not the opposite of Init(). The state that this deletes is
-// lazily created when needed. It is actually the opposite of Load().
-void Cleanup();
-
-void RegisterCallbackImplementation(
- const ::std::function<void(const LogMessage &)> &callback);
-
class ScopedLogRestorer {
public:
- ScopedLogRestorer() = default;
-
- ~ScopedLogRestorer() {
- if (prev_impl_) {
- SetImplementation(std::move(prev_impl_));
- }
- Cleanup();
- }
+ ScopedLogRestorer() : prev_impl_(GetImplementation()) {}
+ ~ScopedLogRestorer() { SetImplementation(std::move(prev_impl_)); }
void Swap(std::shared_ptr<LogImplementation> new_impl) {
- prev_impl_ = SwapImplementation(std::move(new_impl));
+ SetImplementation(std::move(new_impl));
}
private:
diff --git a/aos/logging/implementations_test.cc b/aos/logging/implementations_test.cc
index f6cdc6f..058baab 100644
--- a/aos/logging/implementations_test.cc
+++ b/aos/logging/implementations_test.cc
@@ -92,7 +92,6 @@
}
void TearDown() override {
SetImplementation(nullptr);
- Cleanup();
internal::Context::DeleteNow();
CHECK_EQ(log_implementation.use_count(), 1);
log_implementation.reset();
diff --git a/aos/logging/interface.cc b/aos/logging/interface.cc
index b2f7b75..0cb0cd8 100644
--- a/aos/logging/interface.cc
+++ b/aos/logging/interface.cc
@@ -9,6 +9,8 @@
#include "aos/die.h"
#include "aos/logging/context.h"
+#include "aos/logging/implementations.h"
+#include "glog/logging.h"
namespace aos {
namespace logging {
@@ -21,8 +23,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);
+ PLOG(FATAL) << "vsnprintf(" << output << ", " << size << ", " << format
+ << ", args) failed";
} 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.
@@ -31,39 +33,32 @@
return ::std::min<RetType>(ret, size);
}
-void RunWithCurrentImplementation(
- ::std::function<void(LogImplementation *)> function) {
- Context *context = Context::Get();
-
- const std::shared_ptr<LogImplementation> implementation =
- context->implementation;
- if (implementation == NULL) {
- Die("no logging implementation to use\n");
- }
- function(implementation.get());
-}
-
} // namespace internal
using internal::Context;
-void LogImplementation::DoVLog(log_level level, const char *format,
- va_list ap) {
- auto log_impl = [&](LogImplementation *implementation) {
- va_list ap1;
- va_copy(ap1, ap);
- implementation->DoLog(level, format, ap1);
- va_end(ap1);
-
- if (level == FATAL) {
- VDie(format, ap);
- }
- };
- internal::RunWithCurrentImplementation(::std::ref(log_impl));
-}
-
void VLog(log_level level, const char *format, va_list ap) {
- LogImplementation::DoVLog(level, format, ap);
+ va_list ap1;
+ va_copy(ap1, ap);
+
+ Context *context = Context::Get();
+
+ const std::shared_ptr<LogImplementation> implementation =
+ context->implementation;
+ // Log to the implementation if we have it, and stderr as a backup.
+ if (implementation) {
+ implementation->DoLog(level, format, ap1);
+ } else {
+ aos::logging::LogMessage message;
+ aos::logging::internal::FillInMessage(level, aos::monotonic_clock::now(),
+ format, ap, &message);
+ aos::logging::internal::PrintMessage(stderr, message);
+ }
+ va_end(ap1);
+
+ if (level == FATAL) {
+ VDie(format, ap);
+ }
}
} // namespace logging
diff --git a/aos/logging/interface.h b/aos/logging/interface.h
index 3695e40..387e55d 100644
--- a/aos/logging/interface.h
+++ b/aos/logging/interface.h
@@ -21,30 +21,15 @@
// for the current LogImplementation.
void VLog(log_level level, const char *format, va_list ap)
__attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 2, 0)));
-// Adds to the saved up message.
-void VCork(int line, const char *function, const char *format, va_list ap)
- __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)));
-// Actually logs the saved up message.
-void VUnCork(int line, const char *function, log_level level, const char *file,
- const char *format, va_list ap)
- __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 5, 0)));
// Represents a system that can actually take log messages and do something
// useful with them.
-// All of the code (transitively too!) in the DoLog here can make
-// normal LOG and LOG_DYNAMIC calls but can NOT call LOG_CORK/LOG_UNCORK. These
-// calls will not result in DoLog recursing. However, implementations must be
-// safe to call from multiple threads/tasks at the same time. Also, any other
-// overriden methods may end up logging through a given implementation's DoLog.
class LogImplementation {
public:
LogImplementation() {}
virtual ~LogImplementation() {}
- virtual bool fill_type_cache() { return true; }
-
- protected:
// Actually logs the given message. Implementations should somehow create a
// LogMessage and then call internal::FillInMessage.
__attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0))) virtual void DoLog(
@@ -56,15 +41,6 @@
DoLog(level, format, ap);
va_end(ap);
}
-
- private:
- // These functions call similar methods on the "current" LogImplementation or
- // Die if they can't find one.
- // levels is how many LogImplementations to not use off the stack.
- static void DoVLog(log_level, const char *format, va_list ap)
- __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 2, 0)));
-
- friend void VLog(log_level, const char *, va_list);
};
namespace internal {
@@ -75,12 +51,6 @@
va_list ap)
__attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)));
-// Runs the given function with the current LogImplementation (handles switching
-// it out while running function etc).
-// levels is how many LogImplementations to not use off the stack.
-void RunWithCurrentImplementation(
- int levels, ::std::function<void(LogImplementation *)> function);
-
} // namespace internal
} // namespace logging
} // namespace aos
diff --git a/aos/mutex/mutex_test.cc b/aos/mutex/mutex_test.cc
index 07de9dc..c0ec66e 100644
--- a/aos/mutex/mutex_test.cc
+++ b/aos/mutex/mutex_test.cc
@@ -66,7 +66,6 @@
// Sees what happens with multiple unlocks.
TEST_F(MutexDeathTest, RepeatUnlock) {
- logging::Init();
ASSERT_FALSE(test_mutex_.Lock());
test_mutex_.Unlock();
EXPECT_DEATH(
@@ -80,7 +79,6 @@
// Sees what happens if you unlock without ever locking (or unlocking) it.
TEST_F(MutexDeathTest, NeverLock) {
- logging::Init();
EXPECT_DEATH(
{
logging::SetImplementation(
diff --git a/aos/starter/starter.cc b/aos/starter/starter.cc
index 501530c..fa0daae 100644
--- a/aos/starter/starter.cc
+++ b/aos/starter/starter.cc
@@ -714,8 +714,6 @@
void Run();
void Main() {
- logging::Init();
-
// Set UID to 0 so we can run things as root down below. Since the starter
// program on the roborio runs starter.sh under "lvuser", it will continuously
// fail due to lack of permissions if we do not manually set the UID to admin.
diff --git a/aos/testing/test_logging.cc b/aos/testing/test_logging.cc
index 77bc4e9..b5b71ff 100644
--- a/aos/testing/test_logging.cc
+++ b/aos/testing/test_logging.cc
@@ -22,19 +22,7 @@
public:
const ::std::vector<LogMessage> &messages() { return messages_; }
- // Sets the current thread's time to be monotonic_now for logging.
- void MockTime(::aos::monotonic_clock::time_point monotonic_now) {
- mock_time_ = true;
- monotonic_now_ = monotonic_now;
- }
-
- // Clears any mock time for the current thread.
- void UnMockTime() { mock_time_ = false; }
-
::aos::monotonic_clock::time_point monotonic_now() const override {
- if (mock_time_) {
- return monotonic_now_;
- }
return ::aos::monotonic_clock::now();
}
@@ -70,8 +58,6 @@
}
}
- bool fill_type_cache() override { return false; }
-
void PrintMessagesAsTheyComeIn() { print_as_messages_come_in_ = true; }
// Don't call these from outside this class.
@@ -95,18 +81,8 @@
bool print_as_messages_come_in_ = false;
FILE *output_file_ = stdout;
::aos::Mutex messages_mutex_;
-
- // Thread local storage for mock time. This is thread local because if
- // someone spawns a thread and goes to town in parallel with a simulated event
- // loop, we want to just print the actual monotonic clock out.
- static AOS_THREAD_LOCAL bool mock_time_;
- static AOS_THREAD_LOCAL ::aos::monotonic_clock::time_point monotonic_now_;
};
-AOS_THREAD_LOCAL bool TestLogImplementation::mock_time_ = false;
-AOS_THREAD_LOCAL ::aos::monotonic_clock::time_point
- TestLogImplementation::monotonic_now_ = ::aos::monotonic_clock::min_time;
-
class MyTestEventListener : public ::testing::EmptyTestEventListener {
virtual void OnTestStart(const ::testing::TestInfo & /*test_info*/) {
TestLogImplementation::GetInstance()->ClearMessages();
@@ -138,7 +114,6 @@
};
void *DoEnableTestLogging() {
- logging::Init();
logging::SetImplementation(TestLogImplementation::GetInstance());
::testing::UnitTest::GetInstance()->listeners().Append(
@@ -163,10 +138,5 @@
TestLogImplementation::GetInstance()->PrintMessagesAsTheyComeIn();
}
-void MockTime(::aos::monotonic_clock::time_point monotonic_now) {
- TestLogImplementation::GetInstance()->MockTime(monotonic_now);
-}
-void UnMockTime() { TestLogImplementation::GetInstance()->UnMockTime(); }
-
} // namespace testing
} // namespace aos
diff --git a/aos/testing/test_logging.h b/aos/testing/test_logging.h
index e7059d1..0a26b07 100644
--- a/aos/testing/test_logging.h
+++ b/aos/testing/test_logging.h
@@ -23,13 +23,6 @@
// we want to use graphing tools to verify what's happening.
void ForcePrintLogsDuringTests();
-// Sets the current mock logging time to monotonic_now. This only applies to
-// the current thread.
-void MockTime(::aos::monotonic_clock::time_point monotonic_now);
-// Clears the mock logging time for the current thread and goes back to using
-// monotonic_clock::now().
-void UnMockTime();
-
} // namespace testing
} // namespace aos
diff --git a/aos/transaction/transaction_test.cc b/aos/transaction/transaction_test.cc
index 52b297e..fd76d3f 100644
--- a/aos/transaction/transaction_test.cc
+++ b/aos/transaction/transaction_test.cc
@@ -86,7 +86,6 @@
// Tests that it handles adding too many works intelligently.
TEST_F(WorkStackDeathTest, TooManyWorks) {
- logging::Init();
EXPECT_DEATH(
{
logging::SetImplementation(
diff --git a/aos/vision/tools/camera_primer.cc b/aos/vision/tools/camera_primer.cc
index 027f9dc..fcd7d0b 100644
--- a/aos/vision/tools/camera_primer.cc
+++ b/aos/vision/tools/camera_primer.cc
@@ -26,8 +26,6 @@
// camera_primer
// target_sender
int main(int argc, char **argv) {
- ::aos::logging::Init();
-
aos::vision::CameraParams params;
if (argc != 2) {
diff --git a/frc971/control_loops/drivetrain/libspline.cc b/frc971/control_loops/drivetrain/libspline.cc
index a9820f7..280171f 100644
--- a/frc971/control_loops/drivetrain/libspline.cc
+++ b/frc971/control_loops/drivetrain/libspline.cc
@@ -205,7 +205,6 @@
// Util
void SetUpLogging() {
- ::aos::logging::Init();
::aos::network::OverrideTeamNumber(971);
}
}
diff --git a/frc971/control_loops/drivetrain/trajectory_plot.cc b/frc971/control_loops/drivetrain/trajectory_plot.cc
index 60bd21f..6aff128 100644
--- a/frc971/control_loops/drivetrain/trajectory_plot.cc
+++ b/frc971/control_loops/drivetrain/trajectory_plot.cc
@@ -247,7 +247,6 @@
int main(int argc, char **argv) {
::gflags::ParseCommandLineFlags(&argc, &argv, false);
- ::aos::logging::Init();
::aos::network::OverrideTeamNumber(971);
::frc971::control_loops::drivetrain::Main();
return 0;
diff --git a/y2016/vision/target_sender.cc b/y2016/vision/target_sender.cc
index 3783e9f..bc2a695 100644
--- a/y2016/vision/target_sender.cc
+++ b/y2016/vision/target_sender.cc
@@ -7,8 +7,6 @@
#include <thread>
#include <vector>
-#include "aos/logging/implementations.h"
-#include "aos/logging/logging.h"
#include "aos/time/time.h"
#include "aos/vision/events/socket_types.h"
#include "aos/vision/events/udp.h"
@@ -225,7 +223,6 @@
int main(int, char **) {
using namespace y2016::vision;
StereoGeometry stereo("./stereo_rig.calib");
- ::aos::logging::Init();
std::thread cam0([stereo]() {
RunCamera(0, GetCameraParams(stereo.calibration()),
stereo.calibration().right_camera_name(),
diff --git a/y2017/vision/target_sender.cc b/y2017/vision/target_sender.cc
index 1c5f3f7..7a24d37 100644
--- a/y2017/vision/target_sender.cc
+++ b/y2017/vision/target_sender.cc
@@ -219,7 +219,6 @@
int main(int, char **) {
using namespace y2017::vision;
- ::aos::logging::Init();
VisionConfig cfg;
if (ReadConfiguration("ConfigFile.pb.ascii", &cfg)) {
if (cfg.robot_configs().count("Laptop") != 1) {
diff --git a/y2018/vision/image_streamer.cc b/y2018/vision/image_streamer.cc
index 06a74c4..fb60f1d 100644
--- a/y2018/vision/image_streamer.cc
+++ b/y2018/vision/image_streamer.cc
@@ -288,9 +288,6 @@
int main(int argc, char ** argv) {
gflags::ParseCommandLineFlags(&argc, &argv, false);
- ::aos::logging::Init();
- ::aos::logging::SetImplementation(
- std::make_shared<::aos::logging::StreamLogImplementation>(stderr));
TCPServer<MjpegDataSocket> tcp_server_(80);
aos::vision::CameraParams params0;
diff --git a/y2019/image_streamer/image_streamer.cc b/y2019/image_streamer/image_streamer.cc
index 1252627..6640df0 100644
--- a/y2019/image_streamer/image_streamer.cc
+++ b/y2019/image_streamer/image_streamer.cc
@@ -307,9 +307,6 @@
int main(int argc, char **argv) {
gflags::ParseCommandLineFlags(&argc, &argv, false);
- ::aos::logging::Init();
- ::aos::logging::SetImplementation(
- std::make_shared<::aos::logging::StreamLogImplementation>(stderr));
TCPServer<MjpegDataSocket> tcp_server_(80);
aos::vision::CameraParams params0;
params0.set_exposure(FLAGS_camera0_exposure);
diff --git a/y2019/vision/debug_serial.cc b/y2019/vision/debug_serial.cc
index 18670c0..d1c70c2 100644
--- a/y2019/vision/debug_serial.cc
+++ b/y2019/vision/debug_serial.cc
@@ -23,9 +23,6 @@
using namespace y2019::vision;
using namespace frc971::jevois;
// gflags::ParseCommandLineFlags(&argc, &argv, false);
- ::aos::logging::Init();
- ::aos::logging::SetImplementation(
- std::make_shared<::aos::logging::StreamLogImplementation>(stderr));
int flags = fcntl(0, F_GETFL, 0);
fcntl(0, F_SETFL, flags | O_NONBLOCK);
diff --git a/y2019/vision/global_calibration.cc b/y2019/vision/global_calibration.cc
index af2ad54..e1e5ca8 100644
--- a/y2019/vision/global_calibration.cc
+++ b/y2019/vision/global_calibration.cc
@@ -102,10 +102,6 @@
FLAGS_image_count,
};
- ::aos::logging::Init();
- ::aos::logging::SetImplementation(
- std::make_shared<::aos::logging::StreamLogImplementation>(stderr));
-
TargetFinder target_finder;
ceres::Problem problem;