Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid more noisy message log warnings
  • Loading branch information
nyalldawson committed May 30, 2019
1 parent f44ce97 commit ff365ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
11 changes: 8 additions & 3 deletions src/auth/oauth2/qgsauthoauth2method.cpp
Expand Up @@ -415,8 +415,10 @@ void QgsAuthOAuth2Method::onNetworkError( QNetworkReply::NetworkError err )
QNetworkReply *reply = qobject_cast<QNetworkReply *>( sender() );
if ( !reply )
{
#ifdef QGISDEBUG
msg = tr( "Network error but no reply object accessible" );
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Warning );
QgsDebugMsg( msg );
#endif
return;
}
if ( err != QNetworkReply::NoError && err != QNetworkReply::OperationCanceledError )
Expand All @@ -440,8 +442,11 @@ void QgsAuthOAuth2Method::onNetworkError( QNetworkReply::NetworkError err )
QVariant phrase = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute );
if ( phrase.isValid() )
{
msg = tr( "Network error, HTTP status: %1" ).arg( phrase.toString() );
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Info );
if ( err != QNetworkReply::OperationCanceledError )
{
msg = tr( "Network error, HTTP status: %1" ).arg( phrase.toString() );
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Info );
}
}


Expand Down
9 changes: 6 additions & 3 deletions src/core/qgsblockingnetworkrequest.cpp
Expand Up @@ -372,9 +372,12 @@ void QgsBlockingNetworkRequest::replyFinished()
}
else
{
mErrorMessage = mReply->errorString();
mErrorCode = ServerExceptionError;
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
if ( mReply->error() != QNetworkReply::OperationCanceledError )
{
mErrorMessage = mReply->errorString();
mErrorCode = ServerExceptionError;
QgsMessageLog::logMessage( mErrorMessage, tr( "Network" ) );
}
mReplyContent = QgsNetworkReplyContent( mReply );
}
}
Expand Down
14 changes: 11 additions & 3 deletions src/gui/qgsmessagebar.cpp
Expand Up @@ -276,10 +276,18 @@ void QgsMessageBar::pushItem( QgsMessageBarItem *item )
popWidget( item );
showItem( item );

// Log all messages that are sent to the message bar into the message log so the
// Log all (non-empty) messages that are sent to the message bar into the message log so the
// user can get them back easier.
QString formattedTitle = QStringLiteral( "%1 : %2" ).arg( item->title(), item->text() );
QgsMessageLog::logMessage( formattedTitle, tr( "Messages" ), item->level() );
QString formattedTitle;
if ( !item->title().isEmpty() && !item->text().isEmpty() )
formattedTitle = QStringLiteral( "%1 : %2" ).arg( item->title(), item->text() );
else if ( !item->title().isEmpty() )
formattedTitle = item->title();
else if ( !item->text().isEmpty() )
formattedTitle = item->text();

if ( !formattedTitle.isEmpty() )
QgsMessageLog::logMessage( formattedTitle, tr( "Messages" ), item->level() );
}

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

0 comments on commit ff365ab

Please sign in to comment.