forked from qt-creator/qt-creator
ExecuteFilter: Add timestamps to command outputs
By adding a new function to MessageManager. Change-Id: Ia70d781c0398e8ce0a055ae8fc4718a9081e688f Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
b14351dab8
commit
32935591dd
@@ -134,7 +134,7 @@ void ExecuteFilter::finished(int exitCode, QProcess::ExitStatus status)
|
|||||||
message = tr("Command \"%1\" finished.").arg(commandName);
|
message = tr("Command \"%1\" finished.").arg(commandName);
|
||||||
else
|
else
|
||||||
message = tr("Command \"%1\" failed.").arg(commandName);
|
message = tr("Command \"%1\" failed.").arg(commandName);
|
||||||
MessageManager::write(message);
|
MessageManager::writeWithTime(message);
|
||||||
|
|
||||||
m_taskQueue.dequeue();
|
m_taskQueue.dequeue();
|
||||||
if (!m_taskQueue.isEmpty())
|
if (!m_taskQueue.isEmpty())
|
||||||
@@ -162,18 +162,18 @@ void ExecuteFilter::runHeadCommand()
|
|||||||
const ExecuteData &d = m_taskQueue.head();
|
const ExecuteData &d = m_taskQueue.head();
|
||||||
const Utils::FilePath fullPath = Utils::Environment::systemEnvironment().searchInPath(d.executable);
|
const Utils::FilePath fullPath = Utils::Environment::systemEnvironment().searchInPath(d.executable);
|
||||||
if (fullPath.isEmpty()) {
|
if (fullPath.isEmpty()) {
|
||||||
MessageManager::write(tr("Could not find executable for \"%1\".").arg(d.executable));
|
MessageManager::writeWithTime(tr("Could not find executable for \"%1\".").arg(d.executable));
|
||||||
m_taskQueue.dequeue();
|
m_taskQueue.dequeue();
|
||||||
runHeadCommand();
|
runHeadCommand();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageManager::write(tr("Starting command \"%1\".").arg(headCommand()));
|
MessageManager::writeWithTime(tr("Starting command \"%1\".").arg(headCommand()));
|
||||||
m_process->setWorkingDirectory(d.workingDirectory);
|
m_process->setWorkingDirectory(d.workingDirectory);
|
||||||
m_process->setCommand({fullPath, d.arguments, Utils::CommandLine::Raw});
|
m_process->setCommand({fullPath, d.arguments, Utils::CommandLine::Raw});
|
||||||
m_process->start();
|
m_process->start();
|
||||||
m_process->closeWriteChannel();
|
m_process->closeWriteChannel();
|
||||||
if (!m_process->waitForStarted(1000)) {
|
if (!m_process->waitForStarted(1000)) {
|
||||||
MessageManager::write(tr("Could not start process: %1.").arg(m_process->errorString()));
|
MessageManager::writeWithTime(tr("Could not start process: %1.").arg(m_process->errorString()));
|
||||||
m_taskQueue.dequeue();
|
m_taskQueue.dequeue();
|
||||||
runHeadCommand();
|
runHeadCommand();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QTime>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
@@ -106,6 +107,12 @@ void MessageManager::write(const QString &text, PrintToOutputPaneFlags flags)
|
|||||||
QTimer::singleShot(0, instance(), [text, flags] { doWrite(text, flags); });
|
QTimer::singleShot(0, instance(), [text, flags] { doWrite(text, flags); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageManager::writeWithTime(const QString &text, PrintToOutputPaneFlags flags)
|
||||||
|
{
|
||||||
|
const QString timeStamp = QTime::currentTime().toString("HH:mm:ss ");
|
||||||
|
write(timeStamp + text, flags);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageManager::doWrite(const QString &text, PrintToOutputPaneFlags flags)
|
void MessageManager::doWrite(const QString &text, PrintToOutputPaneFlags flags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_messageOutputWindow, return);
|
QTC_ASSERT(m_messageOutputWindow, return);
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
static void writeMessages(const QStringList &messages,
|
static void writeMessages(const QStringList &messages,
|
||||||
PrintToOutputPaneFlags flags = NoModeSwitch);
|
PrintToOutputPaneFlags flags = NoModeSwitch);
|
||||||
static void write(const QString &text, PrintToOutputPaneFlags flags = NoModeSwitch);
|
static void write(const QString &text, PrintToOutputPaneFlags flags = NoModeSwitch);
|
||||||
|
static void writeWithTime(const QString &text, PrintToOutputPaneFlags flags = NoModeSwitch);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessageManager();
|
MessageManager();
|
||||||
|
|||||||
Reference in New Issue
Block a user