99using System . Text ;
1010using System . Threading ;
1111using System . Threading . Tasks ;
12+ using Microsoft . Extensions . Logging ;
1213using Npgsql . BackendMessages ;
1314using Npgsql . Util ;
1415using static Npgsql . Util . Statics ;
@@ -19,8 +20,6 @@ partial class NpgsqlConnector
1920{
2021 async Task Authenticate ( string username , NpgsqlTimeout timeout , bool async , CancellationToken cancellationToken )
2122 {
22- Log . Trace ( "Authenticating..." , Id ) ;
23-
2423 timeout . CheckAndApply ( this ) ;
2524 var msg = Expect < AuthenticationRequestMessage > ( await ReadMessage ( async ) , this ) ;
2625 switch ( msg . AuthRequestType )
@@ -86,7 +85,7 @@ async Task AuthenticateSASL(List<string> mechanisms, string username, bool async
8685 var sslStream = ( SslStream ) _stream ;
8786 if ( sslStream . RemoteCertificate is null )
8887 {
89- Log . Warn ( "Remote certificate null, falling back to SCRAM-SHA-256" ) ;
88+ Logger . LogWarning ( "Remote certificate null, falling back to SCRAM-SHA-256" ) ;
9089 }
9190 else
9291 {
@@ -96,7 +95,7 @@ async Task AuthenticateSASL(List<string> mechanisms, string username, bool async
9695 var algorithmName = remoteCertificate . SignatureAlgorithm . FriendlyName ;
9796 if ( algorithmName is null )
9897 {
99- Log . Warn ( "Signature algorithm was null, falling back to SCRAM-SHA-256" ) ;
98+ Logger . LogWarning ( "Signature algorithm was null, falling back to SCRAM-SHA-256" ) ;
10099 }
101100 else if ( algorithmName . StartsWith ( "sha1" , StringComparison . OrdinalIgnoreCase ) ||
102101 algorithmName . StartsWith ( "md5" , StringComparison . OrdinalIgnoreCase ) ||
@@ -114,7 +113,8 @@ async Task AuthenticateSASL(List<string> mechanisms, string username, bool async
114113 }
115114 else
116115 {
117- Log . Warn ( $ "Support for signature algorithm { algorithmName } is not yet implemented, falling back to SCRAM-SHA-256") ;
116+ Logger . LogWarning (
117+ $ "Support for signature algorithm { algorithmName } is not yet implemented, falling back to SCRAM-SHA-256") ;
118118 }
119119
120120 if ( hashAlgorithm != null )
@@ -446,7 +446,7 @@ class AuthenticationCompleteException : Exception { }
446446 if ( ProvidePasswordCallback is { } passwordCallback )
447447 try
448448 {
449- Log . Trace ( $ "Taking password from { nameof ( ProvidePasswordCallback ) } delegate") ;
449+ Logger . LogTrace ( $ "Taking password from { nameof ( ProvidePasswordCallback ) } delegate") ;
450450 password = passwordCallback ( Host , Port , Settings . Database ! , username ) ;
451451 }
452452 catch ( Exception e )
@@ -467,7 +467,7 @@ class AuthenticationCompleteException : Exception { }
467467 . GetFirstMatchingEntry ( Host , Port , Settings . Database ! , username ) ;
468468 if ( matchingEntry != null )
469469 {
470- Log . Trace ( "Taking password from pgpass file" ) ;
470+ Logger . LogTrace ( "Taking password from pgpass file" ) ;
471471 password = matchingEntry . Password ;
472472 }
473473 }
0 commit comments