summaryrefslogtreecommitdiffstats
path: root/src/Logger.cpp
diff options
context:
space:
mode:
authortycho <work.tycho@gmail.com>2015-08-30 23:57:43 +0200
committertycho <work.tycho@gmail.com>2015-09-15 17:19:49 +0200
commit3187dbf0aa0943d9eca0c5c1259f8a8ca549709b (patch)
tree82d3aaa2905d360779ea472bc3baf91f8539758b /src/Logger.cpp
parentMerge pull request #2473 from cuberite/APIDumpRename (diff)
downloadcuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar.gz
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar.bz2
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar.lz
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar.xz
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.tar.zst
cuberite-3187dbf0aa0943d9eca0c5c1259f8a8ca549709b.zip
Diffstat (limited to 'src/Logger.cpp')
-rw-r--r--src/Logger.cpp24
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);