1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-20 20:45:10 -05:00

updates to logging

This commit is contained in:
Kyle Spearrin 2019-03-20 08:26:11 -04:00
parent 2f3b38a941
commit 9dedf359e5
3 changed files with 8 additions and 11 deletions

View File

@ -54,15 +54,12 @@ namespace Bit.Core.Services
protected async Task SendAsync(HttpMethod method, string path, object requestModel = null) protected async Task SendAsync(HttpMethod method, string path, object requestModel = null)
{ {
_logger.LogInformation(Constants.BypassFiltersEventId, "SendAsync1");
var tokenStateResponse = await HandleTokenStateAsync(); var tokenStateResponse = await HandleTokenStateAsync();
if(!tokenStateResponse) if(!tokenStateResponse)
{ {
_logger.LogInformation(Constants.BypassFiltersEventId, "SendAsync2");
return; return;
} }
_logger.LogInformation(Constants.BypassFiltersEventId, "SendAsync3");
var message = new TokenHttpRequestMessage(requestModel, AccessToken) var message = new TokenHttpRequestMessage(requestModel, AccessToken)
{ {
Method = method, Method = method,

View File

@ -32,15 +32,12 @@ namespace Bit.Core.Services
globalSettings.Installation?.Id != null && globalSettings.Installation?.Id != null &&
CoreHelpers.SettingHasValue(globalSettings.Installation?.Key)) CoreHelpers.SettingHasValue(globalSettings.Installation?.Key))
{ {
logger.LogInformation(Constants.BypassFiltersEventId, "Use RelayPushNotificationService");
_services.Add(new RelayPushNotificationService(_deviceRepository, globalSettings, _services.Add(new RelayPushNotificationService(_deviceRepository, globalSettings,
httpContextAccessor, relayLogger)); httpContextAccessor, relayLogger));
} }
if(CoreHelpers.SettingHasValue(globalSettings.InternalIdentityKey) && if(CoreHelpers.SettingHasValue(globalSettings.InternalIdentityKey) &&
CoreHelpers.SettingHasValue(globalSettings.BaseServiceUri.InternalNotifications)) CoreHelpers.SettingHasValue(globalSettings.BaseServiceUri.InternalNotifications))
{ {
logger.LogInformation(Constants.BypassFiltersEventId,
"Use NotificationsApiPushNotificationService");
_services.Add(new NotificationsApiPushNotificationService( _services.Add(new NotificationsApiPushNotificationService(
globalSettings, httpContextAccessor, hubLogger)); globalSettings, httpContextAccessor, hubLogger));
} }

View File

@ -43,7 +43,6 @@ namespace Bit.Core.Services
public async Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable<Guid> collectionIds) public async Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable<Guid> collectionIds)
{ {
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay PushSyncCipherUpdateAsync");
await PushCipherAsync(cipher, PushType.SyncCipherUpdate, collectionIds); await PushCipherAsync(cipher, PushType.SyncCipherUpdate, collectionIds);
} }
@ -73,7 +72,6 @@ namespace Bit.Core.Services
RevisionDate = cipher.RevisionDate, RevisionDate = cipher.RevisionDate,
}; };
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay PushCipherAsync");
await SendPayloadToUserAsync(cipher.UserId.Value, type, message, true); 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) private async Task SendPayloadToUserAsync(Guid userId, PushType type, object payload, bool excludeCurrentContext)
{ {
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync1");
var request = new PushSendRequestModel var request = new PushSendRequestModel
{ {
UserId = userId.ToString(), UserId = userId.ToString(),
@ -151,9 +148,9 @@ namespace Bit.Core.Services
Payload = payload Payload = payload
}; };
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync2"); _logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync 1");
await AddCurrentContextAsync(request, excludeCurrentContext); await AddCurrentContextAsync(request, excludeCurrentContext);
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync3"); _logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync 2");
await SendAsync(HttpMethod.Post, "push/send", request); await SendAsync(HttpMethod.Post, "push/send", request);
} }
@ -172,20 +169,26 @@ namespace Bit.Core.Services
private async Task AddCurrentContextAsync(PushSendRequestModel request, bool addIdentifier) private async Task AddCurrentContextAsync(PushSendRequestModel request, bool addIdentifier)
{ {
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 0");
var currentContext = _httpContextAccessor?.HttpContext?. var currentContext = _httpContextAccessor?.HttpContext?.
RequestServices.GetService(typeof(CurrentContext)) as CurrentContext; RequestServices.GetService(typeof(CurrentContext)) as CurrentContext;
if(!string.IsNullOrWhiteSpace(currentContext?.DeviceIdentifier)) if(!string.IsNullOrWhiteSpace(currentContext?.DeviceIdentifier))
{ {
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 1");
var device = await _deviceRepository.GetByIdentifierAsync(currentContext.DeviceIdentifier); var device = await _deviceRepository.GetByIdentifierAsync(currentContext.DeviceIdentifier);
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 2");
if(device != null) if(device != null)
{ {
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 3");
request.DeviceId = device.Id.ToString(); request.DeviceId = device.Id.ToString();
} }
if(addIdentifier) if(addIdentifier)
{ {
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 4");
request.Identifier = currentContext.DeviceIdentifier; request.Identifier = currentContext.DeviceIdentifier;
} }
} }
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 5");
} }
public Task SendPayloadToUserAsync(string userId, PushType type, object payload, string identifier, public Task SendPayloadToUserAsync(string userId, PushType type, object payload, string identifier,