From b2b4f9d1e4562ec246efb5136c1c674ec78f50b7 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 6 Jan 2018 12:28:38 +0100 Subject: Core/Misc: Added compatibility layer for boost 1.66 and future std:: networking stuff * Based on work done by @dimiandre in PR #21173 Closes #21171 Closes #21173 (cherry picked from commit dfd2660a85e4f0891c63009ee8425b2796586409) --- src/common/Logging/Log.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/common/Logging/Log.cpp') diff --git a/src/common/Logging/Log.cpp b/src/common/Logging/Log.cpp index 5a2445b327f..a20beb585a0 100644 --- a/src/common/Logging/Log.cpp +++ b/src/common/Logging/Log.cpp @@ -19,18 +19,18 @@ #include "Log.h" #include "AppenderConsole.h" #include "AppenderFile.h" -#include "AsioHacksImpl.h" #include "Common.h" #include "Config.h" #include "Errors.h" #include "Logger.h" #include "LogMessage.h" #include "LogOperation.h" +#include "Strand.h" #include "Util.h" #include #include -Log::Log() : AppenderId(0), lowestLogLevel(LOG_LEVEL_FATAL), _ioService(nullptr), _strand(nullptr) +Log::Log() : AppenderId(0), lowestLogLevel(LOG_LEVEL_FATAL), _ioContext(nullptr), _strand(nullptr) { m_logsTimestamp = "_" + GetTimestampStr(); RegisterAppender(); @@ -228,11 +228,10 @@ void Log::write(std::unique_ptr&& msg) const { Logger const* logger = GetLoggerByType(msg->type); - if (_ioService) + if (_ioContext) { - auto logOperation = std::make_shared(logger, std::move(msg)); - - _ioService->post(_strand->wrap([logOperation](){ logOperation->call(); })); + std::shared_ptr logOperation = std::make_shared(logger, std::move(msg)); + Trinity::Asio::post(*_ioContext, Trinity::Asio::bind_executor(*_strand, [logOperation]() { logOperation->call(); })); } else logger->write(msg.get()); @@ -358,12 +357,12 @@ Log* Log::instance() return &instance; } -void Log::Initialize(boost::asio::io_service* ioService) +void Log::Initialize(Trinity::Asio::IoContext* ioContext) { - if (ioService) + if (ioContext) { - _ioService = ioService; - _strand = new Trinity::AsioStrand(*ioService); + _ioContext = ioContext; + _strand = new Trinity::Asio::Strand(*ioContext); } LoadFromConfig(); @@ -373,7 +372,7 @@ void Log::SetSynchronous() { delete _strand; _strand = nullptr; - _ioService = nullptr; + _ioContext = nullptr; } void Log::LoadFromConfig() -- cgit v1.2.3