From 9dedf359e58a170c76856bcc3f6879cbbc7a723e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 20 Mar 2019 08:26:11 -0400 Subject: [PATCH] updates to logging --- .../Implementations/BaseIdentityClientService.cs | 3 --- .../MultiServicePushNotificationService.cs | 3 --- .../Implementations/RelayPushNotificationService.cs | 13 ++++++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Core/Services/Implementations/BaseIdentityClientService.cs b/src/Core/Services/Implementations/BaseIdentityClientService.cs index 69d11ea749..5efce253ea 100644 --- a/src/Core/Services/Implementations/BaseIdentityClientService.cs +++ b/src/Core/Services/Implementations/BaseIdentityClientService.cs @@ -54,15 +54,12 @@ namespace Bit.Core.Services protected async Task SendAsync(HttpMethod method, string path, object requestModel = null) { - _logger.LogInformation(Constants.BypassFiltersEventId, "SendAsync1"); var tokenStateResponse = await HandleTokenStateAsync(); if(!tokenStateResponse) { - _logger.LogInformation(Constants.BypassFiltersEventId, "SendAsync2"); return; } - _logger.LogInformation(Constants.BypassFiltersEventId, "SendAsync3"); var message = new TokenHttpRequestMessage(requestModel, AccessToken) { Method = method, diff --git a/src/Core/Services/Implementations/MultiServicePushNotificationService.cs b/src/Core/Services/Implementations/MultiServicePushNotificationService.cs index 13faf7b4ed..6b99c29c17 100644 --- a/src/Core/Services/Implementations/MultiServicePushNotificationService.cs +++ b/src/Core/Services/Implementations/MultiServicePushNotificationService.cs @@ -32,15 +32,12 @@ namespace Bit.Core.Services globalSettings.Installation?.Id != null && CoreHelpers.SettingHasValue(globalSettings.Installation?.Key)) { - logger.LogInformation(Constants.BypassFiltersEventId, "Use RelayPushNotificationService"); _services.Add(new RelayPushNotificationService(_deviceRepository, globalSettings, httpContextAccessor, relayLogger)); } if(CoreHelpers.SettingHasValue(globalSettings.InternalIdentityKey) && CoreHelpers.SettingHasValue(globalSettings.BaseServiceUri.InternalNotifications)) { - logger.LogInformation(Constants.BypassFiltersEventId, - "Use NotificationsApiPushNotificationService"); _services.Add(new NotificationsApiPushNotificationService( globalSettings, httpContextAccessor, hubLogger)); } diff --git a/src/Core/Services/Implementations/RelayPushNotificationService.cs b/src/Core/Services/Implementations/RelayPushNotificationService.cs index 8b37f1862d..a05123479c 100644 --- a/src/Core/Services/Implementations/RelayPushNotificationService.cs +++ b/src/Core/Services/Implementations/RelayPushNotificationService.cs @@ -43,7 +43,6 @@ namespace Bit.Core.Services public async Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable collectionIds) { - _logger.LogInformation(Constants.BypassFiltersEventId, "Relay PushSyncCipherUpdateAsync"); await PushCipherAsync(cipher, PushType.SyncCipherUpdate, collectionIds); } @@ -73,7 +72,6 @@ namespace Bit.Core.Services RevisionDate = cipher.RevisionDate, }; - _logger.LogInformation(Constants.BypassFiltersEventId, "Relay PushCipherAsync"); await SendPayloadToUserAsync(cipher.UserId.Value, type, message, true); } } @@ -143,7 +141,6 @@ namespace Bit.Core.Services private async Task SendPayloadToUserAsync(Guid userId, PushType type, object payload, bool excludeCurrentContext) { - _logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync1"); var request = new PushSendRequestModel { UserId = userId.ToString(), @@ -151,9 +148,9 @@ namespace Bit.Core.Services Payload = payload }; - _logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync2"); + _logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync 1"); await AddCurrentContextAsync(request, excludeCurrentContext); - _logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync3"); + _logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync 2"); await SendAsync(HttpMethod.Post, "push/send", request); } @@ -172,20 +169,26 @@ namespace Bit.Core.Services private async Task AddCurrentContextAsync(PushSendRequestModel request, bool addIdentifier) { + _logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 0"); var currentContext = _httpContextAccessor?.HttpContext?. RequestServices.GetService(typeof(CurrentContext)) as CurrentContext; if(!string.IsNullOrWhiteSpace(currentContext?.DeviceIdentifier)) { + _logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 1"); var device = await _deviceRepository.GetByIdentifierAsync(currentContext.DeviceIdentifier); + _logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 2"); if(device != null) { + _logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 3"); request.DeviceId = device.Id.ToString(); } if(addIdentifier) { + _logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 4"); request.Identifier = currentContext.DeviceIdentifier; } } + _logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 5"); } public Task SendPayloadToUserAsync(string userId, PushType type, object payload, string identifier,