Skip to content

Commit 7674e16

Browse files
committed
[processing] Include version information at start of log
Start the log text with QGIS/Qt/GEOS/GDAL version information strings. This is helpful for debugging and accountability.
1 parent 8ec0262 commit 7674e16

File tree

5 files changed

+78
-8
lines changed

5 files changed

+78
-8
lines changed

python/core/auto_generated/processing/qgsprocessingfeedback.sip.in

+7
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ report the output from executing an external command or subprocess.
9090
.. seealso:: :py:func:`pushDebugInfo`
9191

9292
.. seealso:: :py:func:`pushCommandInfo`
93+
%End
94+
95+
void pushVersionInfo();
96+
%Docstring
97+
Pushes a summary of the QGIS (and underlying library) version information to the log.
98+
99+
.. versionadded:: 3.4.7
93100
%End
94101

95102
};

python/plugins/processing/gui/AlgorithmDialog.py

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def runAlgorithm(self):
205205
break
206206

207207
self.clearProgress()
208+
self.feedback.pushVersionInfo()
208209
self.setProgressText(QCoreApplication.translate('AlgorithmDialog', 'Processing algorithm…'))
209210

210211
self.setInfo(

src/core/processing/qgsprocessingfeedback.cpp

+57-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,63 @@
1616
***************************************************************************/
1717

1818
#include "qgsprocessingfeedback.h"
19+
#include "qgsgeos.h"
20+
#include <ogr_api.h>
21+
#include <gdal_version.h>
22+
#if PROJ_VERSION_MAJOR > 4
23+
#include <proj.h>
24+
#else
25+
#include <proj_api.h>
26+
#endif
27+
28+
void QgsProcessingFeedback::setProgressText( const QString & )
29+
{
30+
}
31+
32+
void QgsProcessingFeedback::reportError( const QString &error, bool )
33+
{
34+
QgsMessageLog::logMessage( error, tr( "Processing" ), Qgis::Critical );
35+
}
36+
37+
void QgsProcessingFeedback::pushInfo( const QString &info )
38+
{
39+
QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info );
40+
}
41+
42+
void QgsProcessingFeedback::pushCommandInfo( const QString &info )
43+
{
44+
QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info );
45+
}
46+
47+
void QgsProcessingFeedback::pushDebugInfo( const QString &info )
48+
{
49+
QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info );
50+
}
51+
52+
void QgsProcessingFeedback::pushConsoleInfo( const QString &info )
53+
{
54+
QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info );
55+
}
56+
57+
void QgsProcessingFeedback::pushVersionInfo()
58+
{
59+
pushDebugInfo( tr( "QGIS version: %1" ).arg( Qgis::QGIS_VERSION ) );
60+
if ( QString( Qgis::QGIS_DEV_VERSION ) != QLatin1String( "exported" ) )
61+
{
62+
pushDebugInfo( tr( "QGIS code revision: %1" ).arg( Qgis::QGIS_DEV_VERSION ) );
63+
}
64+
pushDebugInfo( tr( "Qt version: %1" ).arg( qVersion() ) );
65+
pushDebugInfo( tr( "GDAL version: %1" ).arg( GDALVersionInfo( "RELEASE_NAME" ) ) );
66+
pushDebugInfo( tr( "GEOS version: %1" ).arg( GEOSversion() ) );
67+
68+
#if PROJ_VERSION_MAJOR > 4
69+
PJ_INFO info = proj_info();
70+
pushDebugInfo( tr( "PROJ version: %1.%2.%3" ).arg( PROJ_VERSION_MAJOR ).arg( PROJ_VERSION_MINOR ).arg( PROJ_VERSION_PATCH );
71+
#else
72+
pushDebugInfo( tr( "PROJ version: %1" ).arg( PJ_VERSION ) );
73+
#endif
74+
}
75+
1976

2077
QgsProcessingMultiStepFeedback::QgsProcessingMultiStepFeedback( int childAlgorithmCount, QgsProcessingFeedback *feedback )
2178
: mChildSteps( childAlgorithmCount )
@@ -68,4 +125,3 @@ void QgsProcessingMultiStepFeedback::updateOverallProgress( double progress )
68125
mFeedback->setProgress( baseProgress + currentAlgorithmProgress );
69126
}
70127

71-

src/core/processing/qgsprocessingfeedback.h

+12-6
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class CORE_EXPORT QgsProcessingFeedback : public QgsFeedback
4444
* 4 of 5 layers".
4545
* \see setProgress()
4646
*/
47-
virtual void setProgressText( const QString &text ) { Q_UNUSED( text ); }
47+
virtual void setProgressText( const QString &text );
4848

4949
/**
5050
* Reports that the algorithm encountered an \a error while executing.
5151
*
5252
* If \a fatalError is TRUE then the error prevented the algorithm from executing.
5353
*/
54-
virtual void reportError( const QString &error, bool fatalError = false ) { Q_UNUSED( fatalError ); QgsMessageLog::logMessage( error, tr( "Processing" ), Qgis::Critical ); }
54+
virtual void reportError( const QString &error, bool fatalError = false );
5555

5656
/**
5757
* Pushes a general informational message from the algorithm. This can
@@ -61,7 +61,7 @@ class CORE_EXPORT QgsProcessingFeedback : public QgsFeedback
6161
* \see pushDebugInfo()
6262
* \see pushConsoleInfo()
6363
*/
64-
virtual void pushInfo( const QString &info ) { QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info ); }
64+
virtual void pushInfo( const QString &info );
6565

6666
/**
6767
* Pushes an informational message containing a command from the algorithm.
@@ -71,7 +71,7 @@ class CORE_EXPORT QgsProcessingFeedback : public QgsFeedback
7171
* \see pushDebugInfo()
7272
* \see pushConsoleInfo()
7373
*/
74-
virtual void pushCommandInfo( const QString &info ) { QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info ); }
74+
virtual void pushCommandInfo( const QString &info );
7575

7676
/**
7777
* Pushes an informational message containing debugging helpers from
@@ -80,7 +80,7 @@ class CORE_EXPORT QgsProcessingFeedback : public QgsFeedback
8080
* \see pushCommandInfo()
8181
* \see pushConsoleInfo()
8282
*/
83-
virtual void pushDebugInfo( const QString &info ) { QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info ); }
83+
virtual void pushDebugInfo( const QString &info );
8484

8585
/**
8686
* Pushes a console feedback message from the algorithm. This is used to
@@ -89,7 +89,13 @@ class CORE_EXPORT QgsProcessingFeedback : public QgsFeedback
8989
* \see pushDebugInfo()
9090
* \see pushCommandInfo()
9191
*/
92-
virtual void pushConsoleInfo( const QString &info ) { QgsMessageLog::logMessage( info, tr( "Processing" ), Qgis::Info ); }
92+
virtual void pushConsoleInfo( const QString &info );
93+
94+
/**
95+
* Pushes a summary of the QGIS (and underlying library) version information to the log.
96+
* \since QGIS 3.4.7
97+
*/
98+
void pushVersionInfo();
9399

94100
};
95101

src/gui/processing/qgsprocessingalgorithmdialogbase.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void QgsProcessingAlgorithmDialogBase::pushCommandInfo( const QString &command )
375375

376376
void QgsProcessingAlgorithmDialogBase::pushDebugInfo( const QString &message )
377377
{
378-
txtLog->append( QStringLiteral( "<span style=\"color:blue\">%1</span>" ).arg( formatStringForLog( message.toHtmlEscaped() ) ) );
378+
txtLog->append( QStringLiteral( "<span style=\"color:#777\">%1</span>" ).arg( formatStringForLog( message.toHtmlEscaped() ) ) );
379379
scrollToBottomOfLog();
380380
processEvents();
381381
}

0 commit comments

Comments
 (0)