QLogging: switch the systemd/journald sink to unformatted mode
The extra information is already stored in the journal metadata anyway, so there's no need to duplicate it. This matches the Apple Unified Logger output now. For most people, the visible difference will be that the category name is not included in the plain "journalctl" output. Aug 22 21:25:43 tjmaciei-mobl5 akonadi_imap_resource[4948]: org.kde.pim.kimap: Connection to server lost QAbstractSocket::HostNotFoundError Aug 22 21:27:17 tjmaciei-mobl5 kwin_x11[3376]: kwin_core: XCB error: 3 (BadWindow), sequence: 41165, resource id: 29363347, major code: 129 (SHAPE), minor code:> journalctl does not make it easy to show extra fields, but it's there and can be retrieved with -o verbose. [ChangeLog][QtCore][Logging] The Qt logging framework (qDebug/qWarning/etc) will now only send the plain, unformatted message to systemd's journald, if this backend is enabled. The category and other fields are sent via metadata to journald, so they can be filtered on and retrieved using journalctl. This matches what Qt does for the Apple Logging support and does not apply when Qt is using syslog or stderr to communicate with journald. Change-Id: Ifa1111900d6945ea8e05fffd177de8f47d74ba60 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
This commit is contained in:
parent
48b1af941c
commit
e18b005933
@ -1796,7 +1796,7 @@ static bool slog2_default_handler(QtMsgType type, const QMessageLogContext &,
|
||||
#if QT_CONFIG(journald)
|
||||
static bool systemd_default_message_handler(QtMsgType type,
|
||||
const QMessageLogContext &context,
|
||||
const QString &formattedMessage)
|
||||
const QString &message)
|
||||
{
|
||||
if (shouldLogToStderr())
|
||||
return false; // Leave logging up to stderr handler
|
||||
@ -1820,7 +1820,7 @@ static bool systemd_default_message_handler(QtMsgType type,
|
||||
break;
|
||||
}
|
||||
|
||||
sd_journal_send("MESSAGE=%s", formattedMessage.toUtf8().constData(),
|
||||
sd_journal_send("MESSAGE=%s", message.toUtf8().constData(),
|
||||
"PRIORITY=%i", priority,
|
||||
"CODE_FUNC=%s", context.function ? context.function : "unknown",
|
||||
"CODE_LINE=%d", context.line,
|
||||
@ -2002,7 +2002,7 @@ static constexpr SystemMessageSink systemMessageSink = {
|
||||
#elif QT_CONFIG(slog2)
|
||||
slog2_default_handler
|
||||
#elif QT_CONFIG(journald)
|
||||
systemd_default_message_handler
|
||||
systemd_default_message_handler, true
|
||||
#elif QT_CONFIG(syslog)
|
||||
syslog_default_message_handler
|
||||
#elif defined(Q_OS_ANDROID)
|
||||
|
Loading…
x
Reference in New Issue
Block a user