Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show output of commands in Debug Console #1593

Merged
merged 4 commits into from Jun 5, 2017
Merged

Conversation

@ketanhwr
Copy link
Contributor

@ketanhwr ketanhwr commented Jun 4, 2017

This closes #1552. I've attached a screenshot of the same.

outputconsole

Copy link
Member

@bjorn bjorn left a comment

Looking fine, apart from inline comments. :-)

Would it maybe be helpful to not only write the output of the command, but also a line with the final command being executed? That may help in finding issues with used variables, for example.

Executing: echo "Hello World"
: QProcess(DocumentManager::instance())
, mName(command.name)
, mFinalCommand(command.finalCommand())
, mFinalWorkingDirectory(command.finalWorkingDirectory())
, mLogger(CommandManager::instance()->logger())

This comment has been minimized.

@bjorn

bjorn Jun 4, 2017
Member

If the logger is available from the global CommandManager instance, I don't see a reason to also have it as member of CommandProcess.

@@ -209,12 +216,20 @@ CommandProcess::CommandProcess(const Command &command, bool inTerminal)

connect(this, SIGNAL(finished(int)), SLOT(deleteLater()));

if (showOutput)
connect(this, &QProcess::readyReadStandardOutput, this, &CommandProcess::consoleOutput);

This comment has been minimized.

@bjorn

bjorn Jun 4, 2017
Member

You'll want to also connect to readyReadStandardError or use setProcessChannelMode to merge the standard error channel into the standard out channel.

Of course, it would be nice to report the error channel as appropriate to the LoggingInterface, so that the Debug Console will show errors in red.

if (!mFinalWorkingDirectory.trimmed().isEmpty())
setWorkingDirectory(mFinalWorkingDirectory);

start(mFinalCommand);
}

void CommandProcess::consoleOutput()
{
mLogger->log(LoggingInterface::INFO, QLatin1String(readAllStandardOutput()));

This comment has been minimized.

@bjorn

bjorn Jun 4, 2017
Member

You shouldn't wrap the returned QByteArray with a QLatin1String, cause that will break whenever the encoding of the output is not actually latin1. Since we can't really know the output encoding, we should probably assume local encoding, which means using QString::fromLocal8Bit.

@@ -132,7 +143,7 @@ void CommandDialog::updateWidgets(const QModelIndex &current, const QModelIndex
mUi->exBrowseButton->setEnabled(enable);
mUi->keySequenceEdit->setEnabled(enable);
mUi->clearButton->setEnabled(enable);
mUi->saveBox->setEnabled(enable);

This comment has been minimized.

@bjorn

bjorn Jun 4, 2017
Member

This line shouldn't be deleted, right?

This comment has been minimized.

@ketanhwr

ketanhwr Jun 4, 2017
Author Contributor

Actually I noticed that this line is already there in top 😂

This comment has been minimized.

@ketanhwr

ketanhwr Jun 4, 2017
Author Contributor

So I deleted this one.

<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="outputBox">
<property name="text">
<string>Show Output on Console</string>

This comment has been minimized.

@bjorn

bjorn Jun 4, 2017
Member

Please use "Show output in Debug Console".

@@ -154,7 +154,7 @@
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="outputBox">
<property name="text">
<string>Show Output on Console</string>
<string>Show Output in Debug Console</string>

This comment has been minimized.

@bjorn

bjorn Jun 4, 2017
Member

Small nit: please lowercase "output"

if (showOutput)
if (showOutput) {
CommandManager::instance()->logger()->log(LoggingInterface::INFO,
QString(QLatin1String("Executing: "))

This comment has been minimized.

@bjorn

bjorn Jun 4, 2017
Member

This should really be a translatable string, like tr("Executing: %1").arg(...)

@bjorn bjorn merged commit 74cede0 into mapeditor:master Jun 5, 2017
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@bjorn
Copy link
Member

@bjorn bjorn commented Jun 5, 2017

It's working well, nicely done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.