forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user