Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Send QgsDebugError errors to std::cerr instead of qDebug
Since QgsDebugError should ONLY be used for errors, if we
send them to std::cerr then they'll get correct color formatting
in terminals (e.g. helping with debug output when running
tests)
  • Loading branch information
nyalldawson committed May 20, 2023
1 parent 8a2c0e3 commit 212a456
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/core/qgslogger.cpp
Expand Up @@ -102,7 +102,15 @@ void QgsLogger::debug( const QString &msg, int debuglevel, const char *file, con

if ( sLogFile()->isEmpty() )
{
qDebug( "%s", m.toUtf8().constData() );
if ( debuglevel == 0 )
{
// debug level 0 is for errors only, so highlight these by dumping them to stderr
std::cerr << m.toUtf8().constData() << std::endl;
}
else
{
qDebug( "%s", m.toUtf8().constData() );
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgslogger.h
Expand Up @@ -30,7 +30,7 @@
class QFile;

#ifdef QGISDEBUG
#define QgsDebugError(str) QgsLogger::debug(QString(str), 1, __FILE__, __FUNCTION__, __LINE__)
#define QgsDebugError(str) QgsLogger::debug(QString(str), 0, __FILE__, __FUNCTION__, __LINE__)
#define QgsDebugMsgLevel(str, level) if ( level <= QgsLogger::debugLevel() ) { QgsLogger::debug(QString(str), (level), __FILE__, __FUNCTION__, __LINE__); }(void)(0)
#define QgsDebugCall QgsScopeLogger _qgsScopeLogger(__FILE__, __FUNCTION__, __LINE__)
#else
Expand Down

0 comments on commit 212a456

Please sign in to comment.