From c7a94110987672308ed04b40fd8ed207d1c8d93b Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 24 Oct 2018 13:28:30 +0200 Subject: Be more restrictive about which information is included in logging - Introduce SENSITIVE_DEBUG flag that should be explicitly enabled in order to have certain information included in logging output. - Replace qWarning() with qCWarning() where appropriate. Change-Id: I6386f9cb3ce375101f3c42f407d4af380f1ff75e Reviewed-by: Simon Hausmann Reviewed-by: Jarkko Koivikko --- src/virtualkeyboard/inputcontext.cpp | 13 ++++++++++--- src/virtualkeyboard/virtualkeyboarddebug.h | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/virtualkeyboard/inputcontext.cpp b/src/virtualkeyboard/inputcontext.cpp index 80739819..7a856e21 100644 --- a/src/virtualkeyboard/inputcontext.cpp +++ b/src/virtualkeyboard/inputcontext.cpp @@ -444,7 +444,11 @@ void InputContext::sendKeyClick(int key, const QString &text, int modifiers) if (d->focus && d->inputContext) { QKeyEvent pressEvent(QEvent::KeyPress, key, Qt::KeyboardModifiers(modifiers), text); QKeyEvent releaseEvent(QEvent::KeyRelease, key, Qt::KeyboardModifiers(modifiers), text); - VIRTUALKEYBOARD_DEBUG() << "InputContext::sendKeyClick():" << key; + VIRTUALKEYBOARD_DEBUG().nospace() << "InputContext::sendKeyClick()" +#ifdef SENSITIVE_DEBUG + << ": " << key +#endif + ; d->stateFlags |= InputContextPrivate::KeyEventState; d->inputContext->sendKeyEvent(&pressEvent); @@ -452,8 +456,11 @@ void InputContext::sendKeyClick(int key, const QString &text, int modifiers) if (d->activeKeys.isEmpty()) d->stateFlags &= ~InputContextPrivate::KeyEventState; } else { - qWarning() << "InputContext::sendKeyClick(): no focus to send key click" << key << text - << "- QGuiApplication::focusWindow() is:" << QGuiApplication::focusWindow(); + VIRTUALKEYBOARD_WARN() << "InputContext::sendKeyClick(): no focus to send key click" +#ifdef SENSITIVE_DEBUG + << key << text +#endif + << "- QGuiApplication::focusWindow() is:" << QGuiApplication::focusWindow(); } } diff --git a/src/virtualkeyboard/virtualkeyboarddebug.h b/src/virtualkeyboard/virtualkeyboarddebug.h index 17e53bdf..6dee6372 100644 --- a/src/virtualkeyboard/virtualkeyboarddebug.h +++ b/src/virtualkeyboard/virtualkeyboarddebug.h @@ -35,6 +35,11 @@ Q_DECLARE_LOGGING_CATEGORY(qlcVirtualKeyboard) +// Enables logging of sensitive information, such as key events. +// Should never be enabled by default. +//#define SENSITIVE_DEBUG + #define VIRTUALKEYBOARD_DEBUG() qCDebug(qlcVirtualKeyboard) +#define VIRTUALKEYBOARD_WARN() qCWarning(qlcVirtualKeyboard) #endif // VIRTUALKEYBOARDDEBUG_H -- cgit v1.2.3