From 680f507f3e260eb901ff2af45d083b521def73db Mon Sep 17 00:00:00 2001 From: Abdessattar Sassi <457645+abdes@users.noreply.github.com> Date: Wed, 17 May 2023 19:30:37 +0100 Subject: [PATCH] fix: initialize logger mutex --- logging/include/logging/logging.h | 2 +- logging/src/logging.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/logging/include/logging/logging.h b/logging/include/logging/logging.h index b18d1b8..c0b2169 100644 --- a/logging/include/logging/logging.h +++ b/logging/include/logging/logging.h @@ -145,7 +145,7 @@ class ASAP_LOGGING_API Logger final { std::shared_ptr logger_; /// Synchronization lock used to synchronize logging over this logger from /// multiple threads. - std::unique_ptr logger_mutex_{}; + std::unique_ptr logger_mutex_; /// Logger objects are created only by the Registry class. friend class Registry; diff --git a/logging/src/logging.cpp b/logging/src/logging.cpp index 3e4f81f..089f11a 100644 --- a/logging/src/logging.cpp +++ b/logging/src/logging.cpp @@ -7,6 +7,8 @@ #include "logging/logging.h" #include // std::setw +#include +#include #include // std::ostringstream #include @@ -43,8 +45,9 @@ std::recursive_mutex Registry::loggers_mutex_; // NOLINT // Logger // --------------------------------------------------------------------------- -Logger::Logger(const std::string &name, const spdlog::sink_ptr &sink) { - logger_ = std::make_shared(name, sink); +Logger::Logger(const std::string &name, const spdlog::sink_ptr &sink) + : logger_(std::make_shared(name, sink)), + logger_mutex_(std::make_unique()) { logger_->set_pattern(DEFAULT_LOG_FORMAT); logger_->set_level(spdlog::level::trace); // Ensure that critical errors, especially ASSERT/PANIC, get flushed