diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-07-08 09:00:56 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-07-08 09:00:56 +0200 |
commit | 81c6f744780fee7381e62a702aebba7a5ec4d6f3 (patch) | |
tree | 311adfb56420953072c218f1397c554da951064b /gui/init.cpp | |
parent | 5ae2c39e722abbd7ad69a6ec89dbeac3552f8cf8 (diff) |
gui/init: print loglevel for qDebug() and friends
Diffstat (limited to 'gui/init.cpp')
-rw-r--r-- | gui/init.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/gui/init.cpp b/gui/init.cpp index 96cfcea9..1fd6ff4e 100644 --- a/gui/init.cpp +++ b/gui/init.cpp @@ -111,8 +111,20 @@ static void set_qt_style() # include <alloca.h> #endif -static void qdebug_to_console(QtMsgType, const QMessageLogContext& ctx, const QString &msg) +static void qdebug_to_console(QtMsgType loglevel, const QMessageLogContext& ctx, const QString &msg) { + const char* level; + + switch (loglevel) + { + default: + case QtDebugMsg: level = "DEBUG "; break; + case QtWarningMsg: level = "WARN "; break; + case QtCriticalMsg: level = "CRIT "; break; + case QtFatalMsg: level = "FATAL "; break; + case QtInfoMsg: level = "INFO "; break; + } + #ifdef _WIN32 static_assert(sizeof(wchar_t) == sizeof(decltype(*msg.utf16()))); @@ -139,9 +151,9 @@ static void qdebug_to_console(QtMsgType, const QMessageLogContext& ctx, const QS #endif { if (ctx.file) - std::fprintf(stderr, "[%s:%d]: %ls\n", ctx.file, ctx.line, bytes); + std::fprintf(stderr, "%s[%s:%d]: %ls\n", level, ctx.file, ctx.line, bytes); else - std::fprintf(stderr, "%ls\n", bytes); + std::fprintf(stderr, "%s%ls\n", level, bytes); } std::fflush(stderr); } |