Clean xkb debug output of empty lines

We'd duplicate some \n which made the output more uncomfortable to look
at.
master
Aleix Pol 2020-08-11 13:04:43 +02:00
parent 2a9971fa08
commit 147ee7726e
1 changed files with 9 additions and 5 deletions

14
xkb.cpp
View File

@ -34,23 +34,27 @@ static void xkbLogHandler(xkb_context *context, xkb_log_level priority, const ch
{ {
Q_UNUSED(context) Q_UNUSED(context)
char buf[1024]; char buf[1024];
if (std::vsnprintf(buf, 1023, format, args) <= 0) { int length = std::vsnprintf(buf, 1023, format, args);
while (length > 0 && std::isspace(buf[length - 1])) {
--length;
}
if (length <= 0) {
return; return;
} }
switch (priority) { switch (priority) {
case XKB_LOG_LEVEL_DEBUG: case XKB_LOG_LEVEL_DEBUG:
qCDebug(KWIN_XKB) << "XKB:" << buf; qCDebug(KWIN_XKB, "XKB: %.*s", length, buf);
break; break;
case XKB_LOG_LEVEL_INFO: case XKB_LOG_LEVEL_INFO:
qCInfo(KWIN_XKB) << "XKB:" << buf; qCInfo(KWIN_XKB, "XKB: %.*s", length, buf);
break; break;
case XKB_LOG_LEVEL_WARNING: case XKB_LOG_LEVEL_WARNING:
qCWarning(KWIN_XKB) << "XKB:" << buf; qCWarning(KWIN_XKB, "XKB: %.*s", length, buf);
break; break;
case XKB_LOG_LEVEL_ERROR: case XKB_LOG_LEVEL_ERROR:
case XKB_LOG_LEVEL_CRITICAL: case XKB_LOG_LEVEL_CRITICAL:
default: default:
qCCritical(KWIN_XKB) << "XKB:" << buf; qCCritical(KWIN_XKB, "XKB: %.*s", length, buf);
break; break;
} }
} }