Skip to content

Commit ff365ab

Browse files
committedMay 30, 2019
Avoid more noisy message log warnings
1 parent f44ce97 commit ff365ab

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed
 

‎src/auth/oauth2/qgsauthoauth2method.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,10 @@ void QgsAuthOAuth2Method::onNetworkError( QNetworkReply::NetworkError err )
415415
QNetworkReply *reply = qobject_cast<QNetworkReply *>( sender() );
416416
if ( !reply )
417417
{
418+
#ifdef QGISDEBUG
418419
msg = tr( "Network error but no reply object accessible" );
419-
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Warning );
420+
QgsDebugMsg( msg );
421+
#endif
420422
return;
421423
}
422424
if ( err != QNetworkReply::NoError && err != QNetworkReply::OperationCanceledError )
@@ -440,8 +442,11 @@ void QgsAuthOAuth2Method::onNetworkError( QNetworkReply::NetworkError err )
440442
QVariant phrase = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute );
441443
if ( phrase.isValid() )
442444
{
443-
msg = tr( "Network error, HTTP status: %1" ).arg( phrase.toString() );
444-
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Info );
445+
if ( err != QNetworkReply::OperationCanceledError )
446+
{
447+
msg = tr( "Network error, HTTP status: %1" ).arg( phrase.toString() );
448+
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Info );
449+
}
445450
}
446451

447452

‎src/core/qgsblockingnetworkrequest.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,12 @@ void QgsBlockingNetworkRequest::replyFinished()
372372
}
373373
else
374374
{
375-
mErrorMessage = mReply->errorString();
376-
mErrorCode = ServerExceptionError;
377-
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
375+
if ( mReply->error() != QNetworkReply::OperationCanceledError )
376+
{
377+
mErrorMessage = mReply->errorString();
378+
mErrorCode = ServerExceptionError;
379+
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
380+
}
378381
mReplyContent = QgsNetworkReplyContent( mReply );
379382
}
380383
}

‎src/gui/qgsmessagebar.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,18 @@ void QgsMessageBar::pushItem( QgsMessageBarItem *item )
276276
popWidget( item );
277277
showItem( item );
278278

279-
// Log all messages that are sent to the message bar into the message log so the
279+
// Log all (non-empty) messages that are sent to the message bar into the message log so the
280280
// user can get them back easier.
281-
QString formattedTitle = QStringLiteral( "%1 : %2" ).arg( item->title(), item->text() );
282-
QgsMessageLog::logMessage( formattedTitle, tr( "Messages" ), item->level() );
281+
QString formattedTitle;
282+
if ( !item->title().isEmpty() && !item->text().isEmpty() )
283+
formattedTitle = QStringLiteral( "%1 : %2" ).arg( item->title(), item->text() );
284+
else if ( !item->title().isEmpty() )
285+
formattedTitle = item->title();
286+
else if ( !item->text().isEmpty() )
287+
formattedTitle = item->text();
288+
289+
if ( !formattedTitle.isEmpty() )
290+
QgsMessageLog::logMessage( formattedTitle, tr( "Messages" ), item->level() );
283291
}
284292

285293
QgsMessageBarItem *QgsMessageBar::pushWidget( QWidget *widget, Qgis::MessageLevel level, int duration )

0 commit comments

Comments
 (0)
Please sign in to comment.