diff --git a/src/plugins/projectexplorer/journaldwatcher.cpp b/src/plugins/projectexplorer/journaldwatcher.cpp index 05a2f15796c..29af127bf64 100644 --- a/src/plugins/projectexplorer/journaldwatcher.cpp +++ b/src/plugins/projectexplorer/journaldwatcher.cpp @@ -33,7 +33,6 @@ #include #include -#include #include #include @@ -153,6 +152,17 @@ JournaldWatcher *JournaldWatcher::instance() return m_instance; } +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); + } + return id; +} + bool JournaldWatcher::subscribe(QObject *subscriber, const Subscription &subscription) { // Check that we do not have that subscriber yet: @@ -196,8 +206,7 @@ JournaldWatcher::JournaldWatcher() void JournaldWatcher::handleEntry() { - // process events: - if (!d->m_notifier || sd_journal_process(d->m_journalContext) == SD_JOURNAL_NOP) + if (!d->m_notifier) return; LogEntry logEntry; @@ -209,12 +218,15 @@ void JournaldWatcher::handleEntry() foreach (const JournaldWatcherPrivate::SubscriberInformation &info, d->m_subscriptions) info.subscription(logEntry); - QByteArray tmp = logEntry.value(QByteArrayLiteral("_PID")); - quint64 pid = tmp.isEmpty() ? 0 : QString::fromLatin1(tmp).toInt(); + if (logEntry.value(QByteArrayLiteral("_MACHINE_ID")) != machineId()) + continue; + + const QByteArray pid = logEntry.value(QByteArrayLiteral("_PID")); + quint64 pidNum = pid.isEmpty() ? 0 : QString::fromLatin1(pid).toInt(); QString message = QString::fromUtf8(logEntry.value(QByteArrayLiteral("MESSAGE"))); - emit journaldOutput(pid, message); + emit journaldOutput(pidNum, message); } } diff --git a/src/plugins/projectexplorer/journaldwatcher.h b/src/plugins/projectexplorer/journaldwatcher.h index 9f266ef97e3..98ef53e0516 100644 --- a/src/plugins/projectexplorer/journaldwatcher.h +++ b/src/plugins/projectexplorer/journaldwatcher.h @@ -31,6 +31,8 @@ #ifndef JOURNALDWATCHER_H #define JOURNALDWATCHER_H +#include +#include #include #include @@ -51,6 +53,8 @@ public: static JournaldWatcher *instance(); + static const QByteArray &machineId(); + static bool subscribe(QObject *subscriber, const Subscription &subscription); static void unsubscribe(QObject *subscriber);