Skip to content
Permalink
Browse files

[processing] Fix newlines are stripped from Python traces in log

  • Loading branch information
nyalldawson committed Mar 18, 2018
1 parent 0ef6e1b commit 26bdd920f4892bc97ecdfcf757496b10cf1ddaea
@@ -215,6 +215,13 @@ Hides the short help panel.
%Docstring
Sets the current ``task`` running in the dialog. The task will automatically be started
by the dialog. Ownership of ``task`` is transferred to the dialog.
%End

static QString formatStringForLog( const QString &string );
%Docstring
Formats an input ``string`` for display in the log tab.

.. versionadded:: 3.0.1
%End

protected slots:
@@ -333,21 +333,21 @@ void QgsProcessingAlgorithmDialogBase::pushInfo( const QString &info )

void QgsProcessingAlgorithmDialogBase::pushCommandInfo( const QString &command )
{
txtLog->append( QStringLiteral( "<code>%1<code>" ).arg( command.toHtmlEscaped() ) );
txtLog->append( QStringLiteral( "<code>%1<code>" ).arg( formatStringForLog( command.toHtmlEscaped() ) ) );
scrollToBottomOfLog();
processEvents();
}

void QgsProcessingAlgorithmDialogBase::pushDebugInfo( const QString &message )
{
txtLog->append( QStringLiteral( "<span style=\"color:blue\">%1</span>" ).arg( message.toHtmlEscaped() ) );
txtLog->append( QStringLiteral( "<span style=\"color:blue\">%1</span>" ).arg( formatStringForLog( message.toHtmlEscaped() ) ) );
scrollToBottomOfLog();
processEvents();
}

void QgsProcessingAlgorithmDialogBase::pushConsoleInfo( const QString &info )
{
txtLog->append( QStringLiteral( "<code><span style=\"color:blue\">%1</darkgray></code>" ).arg( info.toHtmlEscaped() ) );
txtLog->append( QStringLiteral( "<code><span style=\"color:blue\">%1</darkgray></code>" ).arg( formatStringForLog( info.toHtmlEscaped() ) ) );
scrollToBottomOfLog();
processEvents();
}
@@ -474,14 +474,21 @@ void QgsProcessingAlgorithmDialogBase::setCurrentTask( QgsProcessingAlgRunnerTas
QgsApplication::taskManager()->addTask( mAlgorithmTask );
}

QString QgsProcessingAlgorithmDialogBase::formatStringForLog( const QString &string )
{
QString s = string;
s.replace( '\n', QStringLiteral( "<br>" ) );
return s;
}

void QgsProcessingAlgorithmDialogBase::setInfo( const QString &message, bool isError, bool escapeHtml )
{
if ( isError )
txtLog->append( QStringLiteral( "<span style=\"color:red\">%1</span>" ).arg( message ) );
txtLog->append( QStringLiteral( "<span style=\"color:red\">%1</span>" ).arg( formatStringForLog( message ) ) );
else if ( escapeHtml )
txtLog->append( message.toHtmlEscaped() );
txtLog->append( formatStringForLog( message.toHtmlEscaped() ) );
else
txtLog->append( message );
txtLog->append( formatStringForLog( message ) );
scrollToBottomOfLog();
processEvents();
}
@@ -260,6 +260,13 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
*/
void setCurrentTask( QgsProcessingAlgRunnerTask *task SIP_TRANSFER );

/**
* Formats an input \a string for display in the log tab.
*
* \since QGIS 3.0.1
*/
static QString formatStringForLog( const QString &string );

protected slots:

/**

0 comments on commit 26bdd92

Please sign in to comment.
You can’t perform that action at this time.