From 8b04ece7f4a7775c5c78da3f6c7775a5e1c0d3e7 Mon Sep 17 00:00:00 2001 From: mordred Date: Thu, 25 Oct 2018 14:47:06 +0200 Subject: [PATCH] Fixed multithreaded logging --- src/common/Logging/Logger.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/Logging/Logger.cpp b/src/common/Logging/Logger.cpp index 3261a4e7..354f38af 100644 --- a/src/common/Logging/Logger.cpp +++ b/src/common/Logging/Logger.cpp @@ -33,7 +33,7 @@ void Logger::init() sinks.push_back( std::make_shared< spdlog::sinks::daily_file_sink_mt >( m_logFile + ".log", 0, 0 ) ); m_logger = std::make_shared< spdlog::logger >( "logger", std::begin( sinks ), std::end( sinks ) ); - + spdlog::register_logger(m_logger); // always flush the log on criticial messages, otherwise it's done by libc // see: https://github.com/gabime/spdlog/wiki/7.-Flush-policy // nb: if the server crashes, log data can be missing from the file unless something logs critical just before it does @@ -50,23 +50,23 @@ void Logger::Log( LoggingSeverity logSev, const std::string& text ) void Logger::error( const std::string& text ) { - m_logger->error( text ); + spdlog::get( "logger" )->error( text ); } void Logger::info( const std::string& text ) { - m_logger->info( text ); + spdlog::get( "logger" )->info( text ); } void Logger::debug( const std::string& text ) { - m_logger->debug( text ); + spdlog::get( "logger" )->debug( text ); } void Logger::fatal( const std::string& text ) { - m_logger->critical( text ); + spdlog::get( "logger" )->critical( text ); } -} \ No newline at end of file +}