From 30157677476281e90810148f741ecf39df29baf8 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 29 Jun 2015 20:01:47 +0200 Subject: [PATCH] Journald: Fix reading of entries logged into journald * Do not use 100% CPU * Do use the correct machine_id Task-number: QTCREATORBUG-14356 Change-Id: Ib6ae9036be83f4f3bb9f7834a1590b492d9a33e1 Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/journaldwatcher.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/journaldwatcher.cpp b/src/plugins/projectexplorer/journaldwatcher.cpp index 29af127bf64..1ea4587addc 100644 --- a/src/plugins/projectexplorer/journaldwatcher.cpp +++ b/src/plugins/projectexplorer/journaldwatcher.cpp @@ -157,8 +157,10 @@ const QByteArray &JournaldWatcher::machineId() static QByteArray id; if (id.isEmpty()) { sd_id128 sdId; - if (sd_id128_get_machine(&sdId) == 0) - id = QByteArray(reinterpret_cast(sdId.bytes), 16); + if (sd_id128_get_machine(&sdId) == 0) { + id.resize(32); + sd_id128_to_string(sdId, id.data()); + } } return id; } @@ -209,6 +211,9 @@ void JournaldWatcher::handleEntry() if (!d->m_notifier) return; + if (sd_journal_process(d->m_journalContext) != SD_JOURNAL_APPEND) + return; + LogEntry logEntry; forever { logEntry = d->retrieveEntry(); @@ -225,6 +230,7 @@ void JournaldWatcher::handleEntry() quint64 pidNum = pid.isEmpty() ? 0 : QString::fromLatin1(pid).toInt(); QString message = QString::fromUtf8(logEntry.value(QByteArrayLiteral("MESSAGE"))); + message.append(QLatin1Char('\n')); // Add newline. emit journaldOutput(pidNum, message); }