diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2013-10-09 14:58:53 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@digia.com> | 2013-10-09 16:27:55 +0300 |
commit | 178722f2fb757b89734f612a835b800ed59975da (patch) | |
tree | dba0e5ee83372590a522ab3b5d6c1ca4d56433fa | |
parent | 1c16e40bb351ab902f4ce13c9a06339bd00317f0 (diff) |
Add an option to forward process messages to qDebug
There has to be a way to get the process debug prints visible without
Creator too. Launching appcontroller with --print-debug will now
forward all process messages to qDebug so they can be seen with
logcat.
Change-Id: Ie50a044fb3f85a45dafd50b90e9de7c58e450a5d
Reviewed-by: Rainer Keller <rainer.keller@digia.com>
-rw-r--r-- | main.cpp | 2 | ||||
-rw-r--r-- | process.cpp | 6 | ||||
-rw-r--r-- | process.h | 8 |
3 files changed, 16 insertions, 0 deletions
@@ -243,6 +243,8 @@ int main(int argc, char **argv) return 0; else return 1; + } else if (arg == "--print-debug") { + config.flags |= Config::PrintDebugMessages; } else { args.prepend(arg); break; diff --git a/process.cpp b/process.cpp index 5e4bab9..b79594f 100644 --- a/process.cpp +++ b/process.cpp @@ -50,6 +50,9 @@ void Process::readyReadStandardOutput() { QByteArray b = mProcess->readAllStandardOutput(); write(1, b.constData(), b.size()); + + if (mConfig.flags.testFlag(Config::PrintDebugMessages)) + qDebug() << b; } void Process::readyReadStandardError() @@ -63,6 +66,9 @@ void Process::readyReadStandardError() mDebug = false; // only search once } write(2, b.constData(), b.size()); + + if (mConfig.flags.testFlag(Config::PrintDebugMessages)) + qDebug() << b; } void Process::setDebug() @@ -5,10 +5,18 @@ class QSocketNotifier; struct Config { + enum Flag { + PrintDebugMessages = 0x01 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + Config() : flags(0) { } + QString base; QString platform; QMap<QString,QString> env; QStringList args; + Flags flags; }; class Process : public QObject |