summaryrefslogtreecommitdiff
path: root/src/logger.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-14 00:56:03 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-14 00:56:20 +0300
commit8e4f4e04ca61594e3dec31bad70eaf6cdf86ad8f (patch)
treeb246d23998da0af196460f42af22b7c89b845b2c /src/logger.h
parentc28aa31fe3d701530280ac92c92e8dff36e65f03 (diff)
downloadmanaverse-8e4f4e04ca61594e3dec31bad70eaf6cdf86ad8f.tar.gz
manaverse-8e4f4e04ca61594e3dec31bad70eaf6cdf86ad8f.tar.bz2
manaverse-8e4f4e04ca61594e3dec31bad70eaf6cdf86ad8f.tar.xz
manaverse-8e4f4e04ca61594e3dec31bad70eaf6cdf86ad8f.zip
add support for thread safe writing to log.
Diffstat (limited to 'src/logger.h')
-rw-r--r--src/logger.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/logger.h b/src/logger.h
index 0941a0e63..c68277ce5 100644
--- a/src/logger.h
+++ b/src/logger.h
@@ -24,7 +24,11 @@
#define LOGGER_H
#include "main.h"
+
+#include <SDL_thread.h>
+
#include <fstream>
+#include <vector>
#include "localconsts.h"
@@ -79,6 +83,19 @@ class Logger final
;
/**
+ * Enters a message in the log (thread safe).
+ */
+ void log_r(const char *const log_text, ...)
+#ifdef __GNUC__
+#ifdef __OpenBSD__
+ __attribute__((__format__(printf, 2, 3)))
+#else
+ __attribute__((__format__(gnu_printf, 2, 3)))
+#endif
+#endif
+ ;
+
+ /**
* Enters a message in the log. The message will be timestamped.
*/
void log1(const char *const log_text);
@@ -88,6 +105,8 @@ class Logger final
*/
void log(const std::string &str);
+ void flush();
+
#ifdef ENABLEDEBUGLOG
/**
* Enters debug message in the log. The message will be timestamped.
@@ -113,6 +132,9 @@ class Logger final
private:
std::ofstream mLogFile;
+ std::vector<std::string> mDelayedLog;
+ SDL_mutex *mMutex;
+ volatile bool mThreadLocked;
bool mLogToStandardOut;
bool mDebugLog;
};