Skip to content

Commit

Permalink
Fix overly noisy o2 debug messages/warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 30, 2019
1 parent d383073 commit 75c720a
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/auth/oauth2/qgsauthoauth2method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ bool QgsAuthOAuth2Method::updateNetworkRequest( QNetworkRequest &request, const
{
case QgsAuthOAuth2Config::Header:
request.setRawHeader( O2_HTTP_AUTHORIZATION_HEADER, QStringLiteral( "Bearer %1" ).arg( o2->token() ).toAscii() );
#ifdef QGISDEBUG
msg = QStringLiteral( "Updated request HEADER with access token for authcfg: %1" ).arg( authcfg );
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Info );
QgsDebugMsgLevel( msg, 2 );
#endif
break;
case QgsAuthOAuth2Config::Form:
// FIXME: what to do here if the parent request is not POST?
Expand All @@ -258,13 +260,17 @@ bool QgsAuthOAuth2Method::updateNetworkRequest( QNetworkRequest &request, const
query.addQueryItem( O2_OAUTH2_ACCESS_TOKEN, o2->token() );
url.setQuery( query );
request.setUrl( url );
#ifdef QGISDEBUG
msg = QStringLiteral( "Updated request QUERY with access token for authcfg: %1" ).arg( authcfg );
#endif
}
else
{
#ifdef QGISDEBUG
msg = QStringLiteral( "Updated request QUERY with access token SKIPPED (existing token) for authcfg: %1" ).arg( authcfg );
#endif
}
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Info );
QgsDebugMsgLevel( msg, 2 );
break;
}

Expand Down Expand Up @@ -296,8 +302,10 @@ bool QgsAuthOAuth2Method::updateNetworkReply( QNetworkReply *reply, const QStrin
//connect( reply, static_cast<void ( QNetworkReply::* )( QNetworkReply::NetworkError )>( &QNetworkReply::error ),
// this, &QgsAuthOAuth2Method::onNetworkError, Qt::QueuedConnection );

#ifdef QGISDEBUG
QString msg = QStringLiteral( "Updated reply with token refresh connection for authcfg: %1" ).arg( authcfg );
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Info );
QgsDebugMsgLevel( msg, 2 );
#endif

return true;
}
Expand Down Expand Up @@ -411,7 +419,7 @@ void QgsAuthOAuth2Method::onNetworkError( QNetworkReply::NetworkError err )
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Warning );
return;
}
if ( err != QNetworkReply::NoError )
if ( err != QNetworkReply::NoError && err != QNetworkReply::OperationCanceledError )
{
msg = tr( "Network error: %1" ).arg( reply->errorString() );
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Warning );
Expand All @@ -422,8 +430,11 @@ void QgsAuthOAuth2Method::onNetworkError( QNetworkReply::NetworkError err )
QVariant status = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute );
if ( !status.isValid() )
{
msg = tr( "Network error but no reply object attributes found" );
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Warning );
if ( err != QNetworkReply::OperationCanceledError )
{
msg = tr( "Network error but no reply object attributes found" );
QgsMessageLog::logMessage( msg, AUTH_METHOD_KEY, Qgis::MessageLevel::Warning );
}
return;
}
QVariant phrase = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute );
Expand Down

0 comments on commit 75c720a

Please sign in to comment.