summaryrefslogtreecommitdiffstats
path: root/src/LogDispacher.h
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-08-10 20:44:49 +0200
committerTycho <work.tycho+git@gmail.com>2014-08-10 20:44:49 +0200
commitbf0050e066af60b5f4060b298118d74cf84dc299 (patch)
treecf2f9afe5cc8e530a005236e270596d66d119c38 /src/LogDispacher.h
parentFirst Implementatation of new Loggin framework (diff)
downloadcuberite-bf0050e066af60b5f4060b298118d74cf84dc299.tar
cuberite-bf0050e066af60b5f4060b298118d74cf84dc299.tar.gz
cuberite-bf0050e066af60b5f4060b298118d74cf84dc299.tar.bz2
cuberite-bf0050e066af60b5f4060b298118d74cf84dc299.tar.lz
cuberite-bf0050e066af60b5f4060b298118d74cf84dc299.tar.xz
cuberite-bf0050e066af60b5f4060b298118d74cf84dc299.tar.zst
cuberite-bf0050e066af60b5f4060b298118d74cf84dc299.zip
Diffstat (limited to 'src/LogDispacher.h')
-rw-r--r--src/LogDispacher.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/LogDispacher.h b/src/LogDispacher.h
new file mode 100644
index 000000000..31b3b3fc1
--- /dev/null
+++ b/src/LogDispacher.h
@@ -0,0 +1,85 @@
+
+#pragma once
+
+
+
+class cLog;
+
+
+namespace Logger
+{
+
+ enum eLogLevel
+ {
+ llRegular,
+ llInfo,
+ llWarning,
+ llError,
+ };
+
+ class cLogDispacher;
+
+ // Must be called before calling GetInstance in a multithreaded context
+ void InitiateMultithreading();
+
+ cLogDispacher & GetInstance(void);
+
+ class cLoggerListener
+ {
+ public:
+ virtual void Log(AString a_Message, eLogLevel a_LogLevel) = 0;
+
+ virtual ~cLoggerListener(){}
+ };
+
+ class cLogDispacher
+ {
+ public:
+
+ void Log (const char * a_Format, Logger::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, Logger::eLogLevel a_LogLevel = Logger::llRegular);
+
+ void AttachListener(Logger::cLoggerListener * a_Listener);
+ void DetachListener(Logger::cLoggerListener * a_Listener);
+
+ private:
+
+ cCriticalSection m_CriticalSection;
+ std::vector<Logger::cLoggerListener *> 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
+
+
+
+