Global logging level now uses atomic to avoid multithreading issues.

This commit is contained in:
Alex Zolotarev 2016-01-19 17:40:21 +03:00 committed by Sergey Yershov
parent 9adc5bbcc3
commit cfae9d4ba4
2 changed files with 10 additions and 6 deletions

View file

@ -92,10 +92,10 @@ namespace my
}
#ifdef DEBUG
LogLevel g_LogLevel = LDEBUG;
LogLevel g_LogAbortLevel = LERROR;
TLogLevel g_LogLevel = {LDEBUG};
TLogLevel g_LogAbortLevel = {LERROR};
#else
LogLevel g_LogLevel = LINFO;
LogLevel g_LogAbortLevel = LCRITICAL;
TLogLevel g_LogLevel = {LINFO};
TLogLevel g_LogAbortLevel = {LCRITICAL};
#endif
}

View file

@ -1,8 +1,11 @@
#pragma once
#include "base/base.hpp"
#include "base/internal/message.hpp"
#include "base/src_point.hpp"
#include "std/atomic.hpp"
namespace my
{
enum LogLevel
@ -14,11 +17,12 @@ namespace my
LCRITICAL
};
typedef atomic<LogLevel> TLogLevel;
typedef void (*LogMessageFn)(LogLevel level, SrcPoint const &, string const &);
extern LogMessageFn LogMessage;
extern LogLevel g_LogLevel;
extern LogLevel g_LogAbortLevel;
extern TLogLevel g_LogLevel;
extern TLogLevel g_LogAbortLevel;
/// @return Pointer to previous message function.
LogMessageFn SetLogMessageFn(LogMessageFn fn);