1212using NuGet . Services . Entities ;
1313using NuGetGallery . Auditing ;
1414using NuGetGallery . Configuration ;
15+ using NuGetGallery . Diagnostics ;
1516using NuGetGallery . Infrastructure . Authentication ;
1617using NuGetGallery . Security ;
1718using Crypto = NuGetGallery . CryptographyService ;
@@ -40,7 +41,7 @@ public class UserService : IUserService
4041
4142 public ITelemetryService TelemetryService { get ; protected set ; }
4243
43- public ILogger < UserService > Logger { get ; protected set ; }
44+ public IDiagnosticsSource DiagnosticsSource { get ; protected set ; }
4445
4546 protected UserService ( ) { }
4647
@@ -56,7 +57,7 @@ public UserService(
5657 IDateTimeProvider dateTimeProvider ,
5758 ICredentialBuilder credentialBuilder ,
5859 ITelemetryService telemetryService ,
59- ILogger < UserService > logger )
60+ IDiagnosticsService diagnosticsService )
6061 : this ( )
6162 {
6263 Config = config ;
@@ -69,7 +70,7 @@ public UserService(
6970 SecurityPolicyService = securityPolicyService ;
7071 DateTimeProvider = dateTimeProvider ;
7172 TelemetryService = telemetryService ;
72- Logger = logger ;
73+ DiagnosticsSource = diagnosticsService . SafeGetSource ( nameof ( UserService ) ) ;
7374 }
7475
7576 public async Task < MembershipRequest > AddMembershipRequestAsync ( Organization organization , string memberName , bool isAdmin )
@@ -598,19 +599,19 @@ private async Task SubscribeOrganizationToTenantPolicyIfTenantIdIsSupported(User
598599 var tenantId = adminUser . Credentials . GetAzureActiveDirectoryCredential ( ) ? . TenantId ;
599600 if ( string . IsNullOrEmpty ( tenantId ) )
600601 {
601- Logger . LogInformation ( "Will not apply tenant policy to organization because admin user does not have an AAD credential." ) ;
602+ DiagnosticsSource . LogInformation ( "Will not apply tenant policy to organization because admin user does not have an AAD credential." ) ;
602603 return ;
603604 }
604605
605606 if ( ! ContentObjectService . LoginDiscontinuationConfiguration . IsTenantIdPolicySupportedForOrganization (
606607 organization . EmailAddress ?? organization . UnconfirmedEmailAddress ,
607608 tenantId ) )
608609 {
609- Logger . LogInformation ( "Will not apply tenant policy to organization because policy is not supported for email-tenant pair." ) ;
610+ DiagnosticsSource . LogInformation ( "Will not apply tenant policy to organization because policy is not supported for email-tenant pair." ) ;
610611 return ;
611612 }
612613
613- Logger . LogInformation ( "Applying tenant policy to organization." ) ;
614+ DiagnosticsSource . LogInformation ( "Applying tenant policy to organization." ) ;
614615 var tenantPolicy = RequireOrganizationTenantPolicy . Create ( tenantId ) ;
615616 await SecurityPolicyService . SubscribeAsync ( organization , tenantPolicy , commitChanges ) ;
616617 }
0 commit comments