summaryrefslogtreecommitdiffstats
path: root/src/Logger.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-08-12 22:43:04 +0200
committermadmaxoft <github@xoft.cz>2014-08-12 22:43:04 +0200
commit10e58f04da038a28626fee90d278c703d55f72b6 (patch)
treefb081bf2edbeaf894bb6be2e8d807348039ec7f0 /src/Logger.cpp
parentFix messing rename (diff)
downloadcuberite-10e58f04da038a28626fee90d278c703d55f72b6.tar
cuberite-10e58f04da038a28626fee90d278c703d55f72b6.tar.gz
cuberite-10e58f04da038a28626fee90d278c703d55f72b6.tar.bz2
cuberite-10e58f04da038a28626fee90d278c703d55f72b6.tar.lz
cuberite-10e58f04da038a28626fee90d278c703d55f72b6.tar.xz
cuberite-10e58f04da038a28626fee90d278c703d55f72b6.tar.zst
cuberite-10e58f04da038a28626fee90d278c703d55f72b6.zip
Diffstat (limited to 'src/Logger.cpp')
-rw-r--r--src/Logger.cpp56
1 files changed, 46 insertions, 10 deletions
diff --git a/src/Logger.cpp b/src/Logger.cpp
index e0ea973f8..572a0e160 100644
--- a/src/Logger.cpp
+++ b/src/Logger.cpp
@@ -2,6 +2,12 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "OSSupport/IsThread.h"
+#ifdef _WIN32
+ #include <time.h>
+#endif
+
+
+
cLogger & cLogger::GetInstance(void)
@@ -10,35 +16,43 @@ cLogger & cLogger::GetInstance(void)
return Instance;
}
+
+
+
+
void cLogger::InitiateMultithreading()
{
GetInstance();
}
+
+
+
+
void cLogger::LogSimple(AString a_Message, eLogLevel a_LogLevel)
{
time_t rawtime;
- time ( &rawtime);
+ time(&rawtime);
- struct tm* timeinfo;
+ struct tm * timeinfo;
#ifdef _MSC_VER
struct tm timeinforeal;
timeinfo = &timeinforeal;
localtime_s(timeinfo, &rawtime);
#else
- timeinfo = localtime( &rawtime);
+ timeinfo = localtime(&rawtime);
#endif
AString Line;
#ifdef _DEBUG
- Printf(Line, "[%04lx|%02d:%02d:%02d] %s\n", cIsThread::GetCurrentID(), timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, a_Message.c_str());
+ Printf(Line, "[%04lx|%02d:%02d:%02d] %s\n", cIsThread::GetCurrentID(), timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, a_Message.c_str());
#else
- Printf(Line, "[%02d:%02d:%02d] %s\n", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, a_Message.c_str());
+ Printf(Line, "[%02d:%02d:%02d] %s\n", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, a_Message.c_str());
#endif
cCSLock Lock(m_CriticalSection);
- for(size_t i = 0; i < m_LogListeners.size(); i++)
+ for (size_t i = 0; i < m_LogListeners.size(); i++)
{
m_LogListeners[i]->Log(a_Message, a_LogLevel);
}
@@ -55,12 +69,20 @@ void cLogger::Log(const char * a_Format, eLogLevel a_LogLevel, va_list a_ArgList
LogSimple(Message, a_LogLevel);
}
+
+
+
+
void cLogger::AttachListener(cListener * a_Listener)
{
cCSLock Lock(m_CriticalSection);
m_LogListeners.push_back(a_Listener);
}
+
+
+
+
void cLogger::DetachListener(cListener * a_Listener)
{
cCSLock Lock(m_CriticalSection);
@@ -69,10 +91,12 @@ void cLogger::DetachListener(cListener * a_Listener)
+
+
////////////////////////////////////////////////////////////////////////////////
// Global functions
-void LOG(const char* a_Format, ...)
+void LOG(const char * a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
@@ -80,7 +104,11 @@ void LOG(const char* a_Format, ...)
va_end(argList);
}
-void LOGINFO(const char* a_Format, ...)
+
+
+
+
+void LOGINFO(const char * a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
@@ -88,7 +116,11 @@ void LOGINFO(const char* a_Format, ...)
va_end(argList);
}
-void LOGWARN(const char* a_Format, ...)
+
+
+
+
+void LOGWARN(const char * a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
@@ -96,7 +128,11 @@ void LOGWARN(const char* a_Format, ...)
va_end(argList);
}
-void LOGERROR(const char* a_Format, ...)
+
+
+
+
+void LOGERROR(const char * a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);