diff options
author | electromatter <electromatter@gmail.com> | 2015-09-22 04:44:34 +0200 |
---|---|---|
committer | electromatter <electromatter@gmail.com> | 2015-09-22 04:44:34 +0200 |
commit | a24cc0184343416eed86b208d8a2aff2b5c0892c (patch) | |
tree | 04ced91aa4a70b4c6e033fac4a2fc2e2ea206205 /src/Logger.cpp | |
parent | added bungeecord support for protocol18x (diff) | |
parent | Merge pull request #2488 from cuberite/ChatFlag (diff) | |
download | cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar.gz cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar.bz2 cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar.lz cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar.xz cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.tar.zst cuberite-a24cc0184343416eed86b208d8a2aff2b5c0892c.zip |
Diffstat (limited to 'src/Logger.cpp')
-rw-r--r-- | src/Logger.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/Logger.cpp b/src/Logger.cpp index 292622a46..60f5a88d2 100644 --- a/src/Logger.cpp +++ b/src/Logger.cpp @@ -1,5 +1,6 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules +#include "Logger.h" #include "OSSupport/IsThread.h" #ifdef _WIN32 @@ -73,10 +74,14 @@ void cLogger::Log(const char * a_Format, eLogLevel a_LogLevel, va_list a_ArgList -void cLogger::AttachListener(cListener * a_Listener) +cLogger::cAttachment cLogger::AttachListener(std::unique_ptr<cListener> a_Listener) { - cCSLock Lock(m_CriticalSection); - m_LogListeners.push_back(a_Listener); + auto nonOwning = a_Listener.get(); + { + cCSLock Lock(m_CriticalSection); + m_LogListeners.push_back(std::move(a_Listener)); + } + return cAttachment{nonOwning}; } @@ -86,7 +91,16 @@ void cLogger::AttachListener(cListener * a_Listener) void cLogger::DetachListener(cListener * a_Listener) { cCSLock Lock(m_CriticalSection); - m_LogListeners.erase(std::remove(m_LogListeners.begin(), m_LogListeners.end(), a_Listener)); + m_LogListeners.erase( + std::remove_if( + m_LogListeners.begin(), + m_LogListeners.end(), + [=](std::unique_ptr<cListener> & a_OtherListener) -> bool + { + return a_OtherListener.get() == a_Listener; + } + ) + ); } @@ -120,7 +134,7 @@ void LOGINFO(const char * a_Format, ...) -void LOGWARN(const char * a_Format, ...) +void LOGWARNING(const char * a_Format, ...) { va_list argList; va_start(argList, a_Format); |