diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-07-03 13:02:51 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-07-04 06:26:13 +0000 |
commit | 9034c6ade6b44345bfb774c4a377e88b604aee8e (patch) | |
tree | 663c5a8bdcef16b90779d9ebf032a5ba8a2a2f7a /src/libs | |
parent | c4512f466afc45efc21411b7d31ecbeae8fd28dd (diff) |
Utils: Add logging category to SynchronousProcess
This helps to debug e.g. runGcc(), which is used for detecting
predefined macros or header paths for the code model.
The log gives also a (limited) overview of the (blocking) processes that
are run on Qt Creator start up.
The produced command line is copy-pastable.
The generated output looks like this:
qtc.utils.synchronousprocess: Starting blocking: /usr/bin/x86_64-linux-gnu-gcc-8 -dumpmachine
qtc.utils.synchronousprocess: SynchronousProcessResponse: result=0 ex=0
17 bytes stdout, stderr=""
qtc.utils.synchronousprocess: Starting blocking: /usr/lib/icecc/bin/clang++ -x c++ -E -dM -
qtc.utils.synchronousprocess: SynchronousProcessResponse: result=1 ex=115
0 bytes stdout, stderr="ICECC[9867] 2019-07-03 13:00:35: couldn't find any clang++\nICECC[9867] 2019-07-03 13:00:35: could not find clang++ in PATH.\n"
"The command \"/usr/lib/icecc/bin/clang++\" terminated with exit code 115."
Change-Id: I9bc7b24121801b0c98c52416848734d850aa9f4d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/utils/synchronousprocess.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp index bfb9d0d296..70e65fc8c9 100644 --- a/src/libs/utils/synchronousprocess.cpp +++ b/src/libs/utils/synchronousprocess.cpp @@ -24,15 +24,18 @@ ****************************************************************************/ #include "synchronousprocess.h" -#include "qtcassert.h" +#include "executeondestruction.h" #include "hostosinfo.h" +#include "qtcassert.h" +#include "qtcprocess.h" #include <QDebug> -#include <QTimer> -#include <QTextCodec> #include <QDir> +#include <QLoggingCategory> #include <QMessageBox> +#include <QTextCodec> #include <QThread> +#include <QTimer> #include <QApplication> @@ -81,6 +84,8 @@ enum { defaultMaxHangTimerCount = 10 }; namespace Utils { +Q_LOGGING_CATEGORY(processLog, "qtc.utils.synchronousprocess", QtWarningMsg); + // A special QProcess derivative allowing for terminal control. class TerminalControllingProcess : public QProcess { public: @@ -445,8 +450,11 @@ SynchronousProcessResponse SynchronousProcess::run(const QString &binary, const QStringList &args, const QByteArray &writeData) { - if (debug) - qDebug() << '>' << Q_FUNC_INFO << binary << args; + qCDebug(processLog).noquote() << "Starting:" + << QtcProcess::joinArgs(QStringList(binary) + args); + ExecuteOnDestruction logResult([this] { + qCDebug(processLog) << d->m_result; + }); d->clearForRun(); @@ -492,13 +500,17 @@ SynchronousProcessResponse SynchronousProcess::run(const QString &binary, QApplication::restoreOverrideCursor(); } - if (debug) - qDebug() << '<' << Q_FUNC_INFO << binary << d->m_result; return d->m_result; } SynchronousProcessResponse SynchronousProcess::runBlocking(const QString &binary, const QStringList &args) { + qCDebug(processLog).noquote() << "Starting blocking:" + << QtcProcess::joinArgs(QStringList(binary) + args); + ExecuteOnDestruction logResult([this] { + qCDebug(processLog) << d->m_result; + }); + d->clearForRun(); // On Windows, start failure is triggered immediately if the |