summaryrefslogtreecommitdiffstats
path: root/src/Logger.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-08-28 15:53:36 +0200
committerMattes D <github@xoft.cz>2014-08-28 15:53:36 +0200
commit52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c (patch)
treec7d8ad9c38a32102bd46e0450d271ea1308828ce /src/Logger.h
parentCheckBasicStyle: Added checking for the "template" keyword. (diff)
parentFixed ItemCategory code example. (diff)
downloadcuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar
cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar.gz
cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar.bz2
cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar.lz
cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar.xz
cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.tar.zst
cuberite-52a6b30f324728aee1c1b8e54b8b4ed9c4e9b60c.zip
Diffstat (limited to 'src/Logger.h')
-rw-r--r--src/Logger.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/Logger.h b/src/Logger.h
new file mode 100644
index 000000000..5e65de8a8
--- /dev/null
+++ b/src/Logger.h
@@ -0,0 +1,73 @@
+
+#pragma once
+
+
+class cLogger
+{
+public:
+
+ enum eLogLevel
+ {
+ llRegular,
+ llInfo,
+ llWarning,
+ llError,
+ };
+
+
+ class cListener
+ {
+ public:
+ virtual void Log(AString a_Message, eLogLevel a_LogLevel) = 0;
+
+ virtual ~cListener(){}
+ };
+
+ void Log (const char * a_Format, eLogLevel a_LogLevel, va_list a_ArgList) FORMATSTRING(2, 0);
+
+ /** Logs the simple text message at the specified log level. */
+ void LogSimple(AString a_Message, eLogLevel a_LogLevel = llRegular);
+
+ void AttachListener(cListener * a_Listener);
+ void DetachListener(cListener * a_Listener);
+
+ static cLogger & GetInstance(void);
+ // Must be called before calling GetInstance in a multithreaded context
+ static void InitiateMultithreading();
+private:
+
+ cCriticalSection m_CriticalSection;
+ std::vector<cListener *> m_LogListeners;
+
+};
+
+
+
+
+
+
+extern void LOG(const char* a_Format, ...) FORMATSTRING(1, 2);
+extern void LOGINFO(const char* a_Format, ...) FORMATSTRING(1, 2);
+extern void LOGWARN(const char* a_Format, ...) FORMATSTRING(1, 2);
+extern void LOGERROR(const char* a_Format, ...) FORMATSTRING(1, 2);
+
+
+
+
+
+// In debug builds, translate LOGD to LOG, otherwise leave it out altogether:
+#ifdef _DEBUG
+ #define LOGD LOG
+#else
+ #define LOGD(...)
+#endif // _DEBUG
+
+
+
+
+
+#define LOGWARNING LOGWARN
+
+
+
+