forked from qt-creator/qt-creator
Utils: Print out QtcProcess number in result debug log
That makes it easier to understand which result belongs to which process. And make the result output a 1-liner in the case of logging, which makes filtering easier. Change-Id: I6da84d28fe2269d2d6dfe6f5a1d300faf5697ca1 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -70,6 +70,7 @@ namespace Utils {
|
||||
namespace Internal {
|
||||
|
||||
const char QTC_PROCESS_BLOCKING_TYPE[] = "__BLOCKING_TYPE__";
|
||||
const char QTC_PROCESS_NUMBER[] = "__NUMBER__";
|
||||
|
||||
class MeasureAndRun
|
||||
{
|
||||
@@ -582,10 +583,12 @@ static QString blockingMessage(const QVariant &variant)
|
||||
void ProcessInterface::defaultStart()
|
||||
{
|
||||
if (processLog().isDebugEnabled()) {
|
||||
static std::atomic_int n = 0;
|
||||
qCDebug(processLog) << "Starting process no." << ++n
|
||||
static std::atomic_int startCounter = 0;
|
||||
const int currentNumber = startCounter.fetch_add(1);
|
||||
qCDebug(processLog) << "Starting process no." << currentNumber
|
||||
<< qPrintable(blockingMessage(property(QTC_PROCESS_BLOCKING_TYPE)))
|
||||
<< m_setup.m_commandLine.toUserOutput();
|
||||
setProperty(QTC_PROCESS_NUMBER, currentNumber);
|
||||
}
|
||||
|
||||
QString program;
|
||||
@@ -675,6 +678,18 @@ QtcProcess::QtcProcess(QObject *parent)
|
||||
static int qProcessProcessErrorMeta = qRegisterMetaType<QProcess::ProcessError>();
|
||||
Q_UNUSED(qProcessExitStatusMeta)
|
||||
Q_UNUSED(qProcessProcessErrorMeta)
|
||||
|
||||
if (processLog().isDebugEnabled()) {
|
||||
connect(this, &QtcProcess::finished, [this] {
|
||||
if (const QVariant n = d->m_process.get()->property(QTC_PROCESS_NUMBER); n.isValid()) {
|
||||
qCDebug(processLog).nospace() << "Process no. " << n.toInt() << " finished: "
|
||||
<< "result=" << result()
|
||||
<< ", ex=" << exitCode()
|
||||
<< ", " << stdOut().size() << " bytes stdout"
|
||||
", stderr=" << stdErr();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
QtcProcess::~QtcProcess()
|
||||
@@ -1505,8 +1520,6 @@ void QtcProcess::runBlocking(QtcProcess::EventLoopMode eventLoopMode)
|
||||
setProperty(QTC_PROCESS_BLOCKING_TYPE, int(eventLoopMode));
|
||||
}
|
||||
|
||||
ExecuteOnDestruction logResult([this] { qCDebug(processLog) << *this; });
|
||||
|
||||
QtcProcess::start();
|
||||
if (processLog().isDebugEnabled()) {
|
||||
// Remove the dynamic property so that it's not reused in subseqent start()
|
||||
|
Reference in New Issue
Block a user