ProjectExplorer: Retrieve output from Journald more reliably

Retrieve output from Journald more reliably.

Change-Id: Ic733698e7ed3717841a5a902c4f1e9e94d952885
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Tobias Hunger
2017-02-27 11:49:00 +01:00
parent 18fe7b3c7e
commit ada3f4ba95
6 changed files with 35 additions and 29 deletions

View File

@@ -48,6 +48,10 @@
#include <ApplicationServices/ApplicationServices.h>
#endif
#if defined (WITH_JOURNALD)
#include "journaldwatcher.h"
#endif
using namespace Utils;
namespace ProjectExplorer {
@@ -541,10 +545,31 @@ public:
RunControl::RunControl(RunConfiguration *runConfiguration, Core::Id mode) :
d(new Internal::RunControlPrivate(runConfiguration, mode))
{ }
{
#ifdef WITH_JOURNALD
JournaldWatcher::instance()->subscribe(this, [this](const JournaldWatcher::LogEntry &entry) {
if (entry.value("_MACHINE_ID") != JournaldWatcher::instance()->machineId())
return;
const QByteArray pid = entry.value("_PID");
if (pid.isEmpty())
return;
const qint64 pidNum = static_cast<qint64>(QString::fromLatin1(pid).toInt());
if (pidNum != d->applicationProcessHandle.pid())
return;
const QString message = QString::fromUtf8(entry.value("MESSAGE")) + "\n";
appendMessageRequested(this, message, Utils::OutputFormat::LogMessageFormat);
});
#endif
}
RunControl::~RunControl()
{
#ifdef WITH_JOURNALD
JournaldWatcher::instance()->unsubscribe(this);
#endif
delete d;
}