summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-09-11 19:58:07 +0300
committerAndrei Karas <akaras@inbox.ru>2017-09-11 23:36:49 +0300
commitb6bf8e607146202b82b7943147fc5a99d4c46a60 (patch)
tree0465526af0ebefee944382af2869f08bfbcc7c94 /src/utils
parentdbf65ef9c85f1b1b93fc9666bda31c5e5171b8c7 (diff)
downloadmv-b6bf8e607146202b82b7943147fc5a99d4c46a60.tar.gz
mv-b6bf8e607146202b82b7943147fc5a99d4c46a60.tar.bz2
mv-b6bf8e607146202b82b7943147fc5a99d4c46a60.tar.xz
mv-b6bf8e607146202b82b7943147fc5a99d4c46a60.zip
Add option to set sdl logging level.
Only for SDL2.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/sdl2helper.cpp5
-rw-r--r--src/utils/sdl2helper.h2
-rw-r--r--src/utils/sdl2logger.cpp15
-rw-r--r--src/utils/sdl2logger.h2
-rw-r--r--src/utils/sdlhelper.cpp4
-rw-r--r--src/utils/sdlhelper.h2
6 files changed, 30 insertions, 0 deletions
diff --git a/src/utils/sdl2helper.cpp b/src/utils/sdl2helper.cpp
index da5b15e41..00893ce82 100644
--- a/src/utils/sdl2helper.cpp
+++ b/src/utils/sdl2helper.cpp
@@ -189,6 +189,11 @@ void SDL::initLogger()
SDL2Logger::init();
}
+void SDL::setLogLevel(const int level)
+{
+ SDL2Logger::setLogLevel(level);
+}
+
void SDL::WaitThread(SDL_Thread *const thread)
{
if (thread != nullptr)
diff --git a/src/utils/sdl2helper.h b/src/utils/sdl2helper.h
index d1b474d50..55d69a75d 100644
--- a/src/utils/sdl2helper.h
+++ b/src/utils/sdl2helper.h
@@ -66,6 +66,8 @@ namespace SDL
void initLogger();
+ void setLogLevel(const int level);
+
void WaitThread(SDL_Thread *const thread);
bool PollEvent(SDL_Event *event);
diff --git a/src/utils/sdl2logger.cpp b/src/utils/sdl2logger.cpp
index 7f7813521..98c7d8338 100644
--- a/src/utils/sdl2logger.cpp
+++ b/src/utils/sdl2logger.cpp
@@ -134,8 +134,23 @@ static SDL_AssertState assertCallback(const SDL_AssertData *data,
void SDL2Logger::init()
{
+#ifdef UNITTESTS
+ SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
+#else // UNITTESTS
+
+ SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
+#endif // UNITTESTS
+
SDL_LogSetOutputFunction(&logCallback, nullptr);
SDL_SetAssertionHandler(&assertCallback, nullptr);
}
+void SDL2Logger::setLogLevel(const int level)
+{
+ if (level > 0)
+ SDL_LogSetAllPriority(static_cast<SDL_LogPriority>(level));
+ else
+ SDL_LogResetPriorities();
+}
+
#endif // USE_SDL2
diff --git a/src/utils/sdl2logger.h b/src/utils/sdl2logger.h
index 78d94ca27..c3ecd1ada 100644
--- a/src/utils/sdl2logger.h
+++ b/src/utils/sdl2logger.h
@@ -28,6 +28,8 @@
namespace SDL2Logger
{
void init();
+
+ void setLogLevel(const int level);
} // namespace SDL2Logger
#endif // USE_SDL2
diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp
index 5a735b5ba..85606f7f7 100644
--- a/src/utils/sdlhelper.cpp
+++ b/src/utils/sdlhelper.cpp
@@ -186,6 +186,10 @@ void SDL::initLogger()
{
}
+void SDL::setLogLevel(const int level A_UNUSED)
+{
+}
+
void SDL::WaitThread(SDL_Thread *const thread)
{
if (thread != nullptr && SDL_GetThreadID(thread) != 0u)
diff --git a/src/utils/sdlhelper.h b/src/utils/sdlhelper.h
index 67a979da3..d388fe7fb 100644
--- a/src/utils/sdlhelper.h
+++ b/src/utils/sdlhelper.h
@@ -72,6 +72,8 @@ namespace SDL
void initLogger();
+ void setLogLevel(const int level);
+
void WaitThread(SDL_Thread *const thread);
bool PollEvent(SDL_Event *event);