Ensure tag used for logging on Android does not contain spaces

Tag passed to __android_log_print shouldn't contain spaces because
filter-spec used by adb logcat expects space-separeate list of
tag:priority specifiers. Effectively, its not possible to filter tag
using logcat if Qt's application name has spaces.

Pick-to: 6.2 6.3
Change-Id: I52b706b7a368d0700db45c0406bbfef279bc61fb
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
This commit is contained in:
Łukasz Korbel 2022-04-04 21:02:38 +07:00
parent e47c22480f
commit f10d0c781e

View File

@ -1737,9 +1737,10 @@ static bool android_default_message_handler(QtMsgType type,
break;
};
// If application name is a tag ensure it has no spaces
// If a category is defined, use it as an Android logging tag
__android_log_print(priority, isDefaultCategory(context.category) ?
qPrintable(QCoreApplication::applicationName()) : context.category,
qPrintable(QCoreApplication::applicationName().replace(" ", "_")) : context.category,
"%s\n", qPrintable(formattedMessage));
return true; // Prevent further output to stderr