diff options
-rw-r--r-- | src/libs/utils/outputformat.h | 1 | ||||
-rw-r--r-- | src/libs/utils/outputformatter.cpp | 4 | ||||
-rw-r--r-- | src/plugins/projectexplorer/applicationlauncher.cpp | 11 | ||||
-rw-r--r-- | src/plugins/projectexplorer/journaldwatcher.cpp | 16 | ||||
-rw-r--r-- | src/plugins/projectexplorer/journaldwatcher.h | 5 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runconfiguration.cpp | 27 |
6 files changed, 35 insertions, 29 deletions
diff --git a/src/libs/utils/outputformat.h b/src/libs/utils/outputformat.h index 6a5f495de0..12b14d5b80 100644 --- a/src/libs/utils/outputformat.h +++ b/src/libs/utils/outputformat.h @@ -31,6 +31,7 @@ enum OutputFormat { NormalMessageFormat, ErrorMessageFormat, + LogMessageFormat, DebugFormat, StdOutFormat, StdErrFormat, diff --git a/src/libs/utils/outputformatter.cpp b/src/libs/utils/outputformatter.cpp index 9706d63b52..64ae503342 100644 --- a/src/libs/utils/outputformatter.cpp +++ b/src/libs/utils/outputformatter.cpp @@ -145,6 +145,10 @@ void OutputFormatter::initFormats() d->formats[ErrorMessageFormat].setFont(boldFont, QTextCharFormat::FontPropertiesSpecifiedOnly); d->formats[ErrorMessageFormat].setForeground(theme->color(Theme::OutputPanes_ErrorMessageTextColor)); + // LogMessageFormat + d->formats[LogMessageFormat].setFont(d->font, QTextCharFormat::FontPropertiesSpecifiedOnly); + d->formats[LogMessageFormat].setForeground(theme->color(Theme::OutputPanes_WarningMessageTextColor)); + // StdOutFormat d->formats[StdOutFormat].setFont(d->font, QTextCharFormat::FontPropertiesSpecifiedOnly); d->formats[StdOutFormat].setForeground(theme->color(Theme::OutputPanes_StdOutTextColor)); diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 45e837402c..e1dfc40c56 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -27,9 +27,6 @@ #ifdef Q_OS_WIN #include "windebuginterface.h" #endif -#ifdef WITH_JOURNALD -#include "journaldwatcher.h" -#endif #include <coreplugin/icore.h> @@ -72,12 +69,12 @@ struct ApplicationLauncherPrivate { Utils::QtcProcess m_guiProcess; Utils::ConsoleProcess m_consoleProcess; ApplicationLauncher::Mode m_currentMode; + // Keep track whether we need to emit a finished signal + bool m_processRunning = false; QTextCodec *m_outputCodec; QTextCodec::ConverterState m_outputCodecState; QTextCodec::ConverterState m_errorCodecState; - // Keep track whether we need to emit a finished signal - bool m_processRunning = false; qint64 m_listeningPid = 0; }; @@ -126,10 +123,6 @@ ApplicationLauncher::ApplicationLauncher(QObject *parent) : QObject(parent), connect(WinDebugInterface::instance(), &WinDebugInterface::debugOutput, this, &ApplicationLauncher::checkDebugOutput, Qt::BlockingQueuedConnection); #endif -#ifdef WITH_JOURNALD - connect(JournaldWatcher::instance(), &JournaldWatcher::journaldOutput, - this, &ApplicationLauncher::checkDebugOutput); -#endif } ApplicationLauncher::~ApplicationLauncher() diff --git a/src/plugins/projectexplorer/journaldwatcher.cpp b/src/plugins/projectexplorer/journaldwatcher.cpp index 5f8bebc83d..5e5acddc22 100644 --- a/src/plugins/projectexplorer/journaldwatcher.cpp +++ b/src/plugins/projectexplorer/journaldwatcher.cpp @@ -163,7 +163,7 @@ bool JournaldWatcher::subscribe(QObject *subscriber, const Subscription &subscri [subscriber](const JournaldWatcherPrivate::SubscriberInformation &info) { return info.subscriber == subscriber; }); - QTC_ASSERT(pos >= 0, return false); + QTC_ASSERT(pos < 0, return false); d->m_subscriptions.append(JournaldWatcherPrivate::SubscriberInformation(subscriber, subscription)); connect(subscriber, &QObject::destroyed, m_instance, &JournaldWatcher::unsubscribe); @@ -214,20 +214,6 @@ void JournaldWatcher::handleEntry() foreach (const JournaldWatcherPrivate::SubscriberInformation &info, d->m_subscriptions) info.subscription(logEntry); - - if (logEntry.value(QByteArrayLiteral("_MACHINE_ID")) != machineId()) - continue; - - const QByteArray pid = logEntry.value(QByteArrayLiteral("_PID")); - if (pid.isEmpty()) - continue; - - quint64 pidNum = QString::fromLatin1(pid).toInt(); - - QString message = QString::fromUtf8(logEntry.value(QByteArrayLiteral("MESSAGE"))); - message.append(QLatin1Char('\n')); // Add newline. - - emit journaldOutput(pidNum, message); } } diff --git a/src/plugins/projectexplorer/journaldwatcher.h b/src/plugins/projectexplorer/journaldwatcher.h index 27ed739142..ab6d1a6dda 100644 --- a/src/plugins/projectexplorer/journaldwatcher.h +++ b/src/plugins/projectexplorer/journaldwatcher.h @@ -41,7 +41,7 @@ class JournaldWatcher : public QObject public: typedef QMap<QByteArray, QByteArray> LogEntry; - typedef std::function<void(LogEntry)> Subscription; + typedef std::function<void(const LogEntry&)> Subscription; ~JournaldWatcher() override; @@ -52,9 +52,6 @@ public: static bool subscribe(QObject *subscriber, const Subscription &subscription); static void unsubscribe(QObject *subscriber); -signals: - void journaldOutput(quint64 pid, const QString &message); - private: JournaldWatcher(); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 59cb896ca1..e21f9fb3f8 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -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; } |