diff options
Diffstat (limited to 'src/server/shared/Logging/Log.h')
-rw-r--r-- | src/server/shared/Logging/Log.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/server/shared/Logging/Log.h b/src/server/shared/Logging/Log.h index a118e6e8773..e739c9eaf4e 100644 --- a/src/server/shared/Logging/Log.h +++ b/src/server/shared/Logging/Log.h @@ -22,18 +22,17 @@ #include "Define.h" #include "Appender.h" #include "Logger.h" -#include "LogWorker.h" +#include <stdarg.h> +#include <boost/asio/io_service.hpp> +#include <boost/asio/strand.hpp> #include <unordered_map> #include <string> -#include <ace/Singleton.h> #define LOGGER_ROOT "root" class Log { - friend class ACE_Singleton<Log, ACE_Thread_Mutex>; - typedef std::unordered_map<std::string, Logger> LoggerMap; private: @@ -41,6 +40,20 @@ class Log ~Log(); public: + + static Log* instance(boost::asio::io_service* ioService = nullptr) + { + static Log* instance = new Log(); + + if (ioService != nullptr) + { + instance->_ioService = ioService; + instance->_strand = new boost::asio::strand(*ioService); + } + + return instance; + } + void LoadFromConfig(); void Close(); bool ShouldLog(std::string const& type, LogLevel level) const; @@ -73,7 +86,8 @@ class Log std::string m_logsDir; std::string m_logsTimestamp; - LogWorker* worker; + boost::asio::io_service* _ioService; + boost::asio::strand* _strand; }; inline Logger const* Log::GetLoggerByType(std::string const& type) const @@ -117,7 +131,7 @@ inline void Log::outMessage(std::string const& filter, LogLevel level, const cha va_end(ap); } -#define sLog ACE_Singleton<Log, ACE_Thread_Mutex>::instance() +#define sLog Log::instance() #if PLATFORM != PLATFORM_WINDOWS #define TC_LOG_MESSAGE_BODY(filterType__, level__, ...) \ |