diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Infrastructure/GrpcExceptionInterceptor.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Infrastructure/GrpcExceptionInterceptor.cs index c434074d3..ec159a0ea 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Infrastructure/GrpcExceptionInterceptor.cs +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Infrastructure/GrpcExceptionInterceptor.cs @@ -28,7 +28,7 @@ public class GrpcExceptionInterceptor : Interceptor } catch (RpcException e) { - _logger.LogError("Error calling via grpc: {Status} - {Message}", e.Status, e.Message); + _logger.LogError(e, "Error calling via gRPC: {Status}", e.Status); return default; } } diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Infrastructure/GrpcExceptionInterceptor.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Infrastructure/GrpcExceptionInterceptor.cs index 20adb2fc7..9611c6177 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Infrastructure/GrpcExceptionInterceptor.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Infrastructure/GrpcExceptionInterceptor.cs @@ -28,7 +28,7 @@ public class GrpcExceptionInterceptor : Interceptor } catch (RpcException e) { - _logger.LogError("Error calling via grpc: {Status} - {Message}", e.Status, e.Message); + _logger.LogError(e, "Error calling via gRPC: {Status}", e.Status); return default; } } diff --git a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/DefaultRabbitMQPersistentConnection.cs b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/DefaultRabbitMQPersistentConnection.cs index 48714cd2f..4f3f573f5 100644 --- a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/DefaultRabbitMQPersistentConnection.cs +++ b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/DefaultRabbitMQPersistentConnection.cs @@ -59,7 +59,7 @@ public class DefaultRabbitMQPersistentConnection .Or() .WaitAndRetry(_retryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) => { - _logger.LogWarning(ex, "RabbitMQ Client could not connect after {TimeOut}s ({ExceptionMessage})", $"{time.TotalSeconds:n1}", ex.Message); + _logger.LogWarning(ex, "RabbitMQ Client could not connect after {TimeOut}s", $"{time.TotalSeconds:n1}"); } ); @@ -81,7 +81,7 @@ public class DefaultRabbitMQPersistentConnection } else { - _logger.LogCritical("FATAL ERROR: RabbitMQ connections could not be created and opened"); + _logger.LogCritical("Fatal error: RabbitMQ connections could not be created and opened"); return false; } diff --git a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs index 8826b88e6..aa4dc17ef 100644 --- a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs +++ b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.cs @@ -57,7 +57,7 @@ public class EventBusRabbitMQ : IEventBus, IDisposable .Or() .WaitAndRetry(_retryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) => { - _logger.LogWarning(ex, "Could not publish event: {EventId} after {Timeout}s ({ExceptionMessage})", @event.Id, $"{time.TotalSeconds:n1}", ex.Message); + _logger.LogWarning(ex, "Could not publish event: {EventId} after {Timeout}s", @event.Id, $"{time.TotalSeconds:n1}"); }); var eventName = @event.GetType().Name; @@ -193,7 +193,7 @@ public class EventBusRabbitMQ : IEventBus, IDisposable } catch (Exception ex) { - _logger.LogWarning(ex, "----- ERROR Processing message \"{Message}\"", message); + _logger.LogWarning(ex, "Error Processing message \"{Message}\"", message); } // Even on exception we take the message off the queue. diff --git a/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.cs b/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.cs index c409717d6..10abbfafc 100644 --- a/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.cs +++ b/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.cs @@ -140,7 +140,7 @@ public class EventBusServiceBus : IEventBus, IAsyncDisposable var ex = args.Exception; var context = args.ErrorSource; - _logger.LogError(ex, "ERROR handling message: {ExceptionMessage} - Context: {@ExceptionContext}", ex.Message, context); + _logger.LogError(ex, "Error handling message - Context: {@ExceptionContext}", context); return Task.CompletedTask; } diff --git a/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHostExtensions.cs b/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHostExtensions.cs index aff7df81b..f4dbee68e 100644 --- a/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHostExtensions.cs +++ b/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHostExtensions.cs @@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Hosting sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), onRetry: (exception, timeSpan, retry, ctx) => { - logger.LogWarning(exception, "[{prefix}] Exception {ExceptionType} with message {Message} detected on attempt {retry} of {retries}", nameof(TContext), exception.GetType().Name, exception.Message, retry, retries); + logger.LogWarning(exception, "[{prefix}] Error migrating database (attempt {retry} of {retries})", nameof(TContext), retry, retries); }); //if the sql server container is not created on run docker compose this diff --git a/src/Services/Basket/Basket.API/Controllers/BasketController.cs b/src/Services/Basket/Basket.API/Controllers/BasketController.cs index 4bb3b22f6..b971c96e9 100644 --- a/src/Services/Basket/Basket.API/Controllers/BasketController.cs +++ b/src/Services/Basket/Basket.API/Controllers/BasketController.cs @@ -71,7 +71,7 @@ public class BasketController : ControllerBase } catch (Exception ex) { - _logger.LogError(ex, "ERROR Publishing integration event: {IntegrationEventId}", eventMessage.Id); + _logger.LogError(ex, "Error Publishing integration event: {IntegrationEventId}", eventMessage.Id); throw; } diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs index df18a065c..8796197c0 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs @@ -17,7 +17,7 @@ public class OrderStartedIntegrationEventHandler : IIntegrationEventHandler> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); await _repository.DeleteBasketAsync(@event.UserId.ToString()); } diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs index cff2faa05..94c39cd5e 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs @@ -17,7 +17,7 @@ public class ProductPriceChangedIntegrationEventHandler : IIntegrationEventHandl { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); var userIds = _repository.GetUsers(); @@ -36,7 +36,7 @@ public class ProductPriceChangedIntegrationEventHandler : IIntegrationEventHandl if (itemsToUpdate != null) { - _logger.LogInformation("----- ProductPriceChangedIntegrationEventHandler - Updating items in basket for user: {BuyerId} ({@Items})", basket.BuyerId, itemsToUpdate); + _logger.LogInformation("ProductPriceChangedIntegrationEventHandler - Updating items in basket for user: {BuyerId} ({@Items})", basket.BuyerId, itemsToUpdate); foreach (var item in itemsToUpdate) { diff --git a/src/Services/Basket/Basket.UnitTests/Application/CartControllerTest.cs b/src/Services/Basket/Basket.UnitTests/Application/CartControllerTest.cs index 4231d6a9e..44d565f39 100644 --- a/src/Services/Basket/Basket.UnitTests/Application/CartControllerTest.cs +++ b/src/Services/Basket/Basket.UnitTests/Application/CartControllerTest.cs @@ -79,7 +79,7 @@ public class CartControllerTest //Arrange var fakeCatalogItem = GetFakeCatalogItem(); - _basketServiceMock.Setup(x => x.AddItemToBasket(It.IsAny(), It.IsAny())) + _basketServiceMock.Setup(x => x.AddItemToBasket(It.IsAny(), It.IsAny())) .Returns(Task.FromResult(1)); //Act diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs index db154cb7f..472f392c9 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs @@ -60,14 +60,14 @@ public class CatalogContextSeed } catch (Exception ex) { - logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); + logger.LogError(ex, "Error reading CSV headers"); return GetPreconfiguredCatalogBrands(); } return File.ReadAllLines(csvFileCatalogBrands) .Skip(1) // skip header row - .SelectTry(x => CreateCatalogBrand(x)) - .OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; }) + .SelectTry(CreateCatalogBrand) + .OnCaughtException(ex => { logger.LogError(ex, "Error creating brand while seeding database"); return null; }) .Where(x => x != null); } @@ -75,9 +75,9 @@ public class CatalogContextSeed { brand = brand.Trim('"').Trim(); - if (String.IsNullOrEmpty(brand)) + if (string.IsNullOrEmpty(brand)) { - throw new Exception("catalog Brand Name is empty"); + throw new Exception("Catalog Brand Name is empty"); } return new CatalogBrand @@ -115,14 +115,14 @@ public class CatalogContextSeed } catch (Exception ex) { - logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); + logger.LogError(ex, "Error reading CSV headers"); return GetPreconfiguredCatalogTypes(); } return File.ReadAllLines(csvFileCatalogTypes) .Skip(1) // skip header row .SelectTry(x => CreateCatalogType(x)) - .OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; }) + .OnCaughtException(ex => { logger.LogError(ex, "Error creating catalog type while seeding database"); return null; }) .Where(x => x != null); } @@ -130,7 +130,7 @@ public class CatalogContextSeed { type = type.Trim('"').Trim(); - if (String.IsNullOrEmpty(type)) + if (string.IsNullOrEmpty(type)) { throw new Exception("catalog Type Name is empty"); } @@ -170,7 +170,7 @@ public class CatalogContextSeed } catch (Exception ex) { - logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); + logger.LogError(ex, "Error reading CSV headers"); return GetPreconfiguredItems(); } @@ -181,11 +181,11 @@ public class CatalogContextSeed .Skip(1) // skip header row .Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)")) .SelectTry(column => CreateCatalogItem(column, csvheaders, catalogTypeIdLookup, catalogBrandIdLookup)) - .OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; }) + .OnCaughtException(ex => { logger.LogError(ex, "Error creating catalog item while seeding database"); return null; }) .Where(x => x != null); } - private CatalogItem CreateCatalogItem(string[] column, string[] headers, Dictionary catalogTypeIdLookup, Dictionary catalogBrandIdLookup) + private CatalogItem CreateCatalogItem(string[] column, string[] headers, Dictionary catalogTypeIdLookup, Dictionary catalogBrandIdLookup) { if (column.Count() != headers.Count()) { @@ -205,7 +205,7 @@ public class CatalogContextSeed } string priceString = column[Array.IndexOf(headers, "price")].Trim('"').Trim(); - if (!Decimal.TryParse(priceString, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out Decimal price)) + if (!decimal.TryParse(priceString, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out decimal price)) { throw new Exception($"price={priceString}is not a valid decimal number"); } @@ -224,7 +224,7 @@ public class CatalogContextSeed if (availableStockIndex != -1) { string availableStockString = column[availableStockIndex].Trim('"').Trim(); - if (!String.IsNullOrEmpty(availableStockString)) + if (!string.IsNullOrEmpty(availableStockString)) { if (int.TryParse(availableStockString, out int availableStock)) { @@ -241,7 +241,7 @@ public class CatalogContextSeed if (restockThresholdIndex != -1) { string restockThresholdString = column[restockThresholdIndex].Trim('"').Trim(); - if (!String.IsNullOrEmpty(restockThresholdString)) + if (!string.IsNullOrEmpty(restockThresholdString)) { if (int.TryParse(restockThresholdString, out int restockThreshold)) { @@ -258,7 +258,7 @@ public class CatalogContextSeed if (maxStockThresholdIndex != -1) { string maxStockThresholdString = column[maxStockThresholdIndex].Trim('"').Trim(); - if (!String.IsNullOrEmpty(maxStockThresholdString)) + if (!string.IsNullOrEmpty(maxStockThresholdString)) { if (int.TryParse(maxStockThresholdString, out int maxStockThreshold)) { @@ -275,7 +275,7 @@ public class CatalogContextSeed if (onReorderIndex != -1) { string onReorderString = column[onReorderIndex].Trim('"').Trim(); - if (!String.IsNullOrEmpty(onReorderString)) + if (!string.IsNullOrEmpty(onReorderString)) { if (bool.TryParse(onReorderString, out bool onReorder)) { @@ -361,7 +361,7 @@ public class CatalogContextSeed sleepDurationProvider: retry => TimeSpan.FromSeconds(5), onRetry: (exception, timeSpan, retry, ctx) => { - logger.LogWarning(exception, "[{prefix}] Exception {ExceptionType} with message {Message} detected on attempt {retry} of {retries}", prefix, exception.GetType().Name, exception.Message, retry, retries); + logger.LogWarning(exception, "[{prefix}] Error seeding database (attempt {retry} of {retries})", prefix, retry, retries); } ); } diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs index 15cbb7ff7..44c7b8c75 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs @@ -26,7 +26,7 @@ public class CatalogIntegrationEventService : ICatalogIntegrationEventService, I { try { - _logger.LogInformation("----- Publishing integration event: {IntegrationEventId_published} - ({@IntegrationEvent})", evt.Id, evt); + _logger.LogInformation("Publishing integration event: {IntegrationEventId_published} - ({@IntegrationEvent})", evt.Id, evt); await _eventLogService.MarkEventAsInProgressAsync(evt.Id); _eventBus.Publish(evt); @@ -34,14 +34,14 @@ public class CatalogIntegrationEventService : ICatalogIntegrationEventService, I } catch (Exception ex) { - _logger.LogError(ex, "ERROR Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", evt.Id, evt); + _logger.LogError(ex, "Error Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", evt.Id, evt); await _eventLogService.MarkEventAsFailedAsync(evt.Id); } } public async Task SaveEventAndCatalogContextChangesAsync(IntegrationEvent evt) { - _logger.LogInformation("----- CatalogIntegrationEventService - Saving changes and integrationEvent: {IntegrationEventId}", evt.Id); + _logger.LogInformation("CatalogIntegrationEventService - Saving changes and integrationEvent: {IntegrationEventId}", evt.Id); //Use of an EF Core resiliency strategy when using multiple DbContexts within an explicit BeginTransaction(): //See: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs index fb79b96e9..6ad0a3867 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs @@ -21,7 +21,7 @@ public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler : { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); var confirmedOrderStockItems = new List(); diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs index 99b755568..48e7fe571 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs @@ -18,7 +18,7 @@ public class OrderStatusChangedToPaidIntegrationEventHandler : { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); //we're not blocking stock/inventory foreach (var orderStockItem in @event.OrderStockItems) diff --git a/src/Services/Identity/Identity.API/IWebHostExtensions.cs b/src/Services/Identity/Identity.API/IWebHostExtensions.cs index 734ae3fde..a9e002d74 100644 --- a/src/Services/Identity/Identity.API/IWebHostExtensions.cs +++ b/src/Services/Identity/Identity.API/IWebHostExtensions.cs @@ -1,4 +1,4 @@ -namespace Microsoft.AspNetCore.Hosting +namespace Microsoft.AspNetCore.Hosting { public static class IWebHostExtensions { @@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Hosting sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), onRetry: (exception, timeSpan, retry, ctx) => { - logger.LogWarning(exception, "[{prefix}] Exception {ExceptionType} with message {Message} detected on attempt {retry} of {retries}", nameof(TContext), exception.GetType().Name, exception.Message, retry, retries); + logger.LogWarning(exception, "[{prefix}] Error seeding database (attempt {retry} of {retries})", nameof(TContext), retry, retries); }); //if the sql server container is not created on run docker compose this diff --git a/src/Services/Identity/Identity.API/Quickstart/Account/LoginViewModel.cs b/src/Services/Identity/Identity.API/Quickstart/Account/LoginViewModel.cs index 753f4773e..f539c70e9 100644 --- a/src/Services/Identity/Identity.API/Quickstart/Account/LoginViewModel.cs +++ b/src/Services/Identity/Identity.API/Quickstart/Account/LoginViewModel.cs @@ -10,7 +10,7 @@ public class LoginViewModel : LoginInputModel public bool EnableLocalLogin { get; set; } = true; public IEnumerable ExternalProviders { get; set; } = Enumerable.Empty(); - public IEnumerable VisibleExternalProviders => ExternalProviders.Where(x => !String.IsNullOrWhiteSpace(x.DisplayName)); + public IEnumerable VisibleExternalProviders => ExternalProviders.Where(x => !string.IsNullOrWhiteSpace(x.DisplayName)); public bool IsExternalLoginOnly => EnableLocalLogin == false && ExternalProviders?.Count() == 1; public string ExternalLoginScheme => IsExternalLoginOnly ? ExternalProviders?.SingleOrDefault()?.AuthenticationScheme : null; diff --git a/src/Services/Identity/Identity.API/Quickstart/Consent/ConsentController.cs b/src/Services/Identity/Identity.API/Quickstart/Consent/ConsentController.cs index 1255df44a..2cdf323ec 100644 --- a/src/Services/Identity/Identity.API/Quickstart/Consent/ConsentController.cs +++ b/src/Services/Identity/Identity.API/Quickstart/Consent/ConsentController.cs @@ -217,7 +217,7 @@ public class ConsentController : Controller public ScopeViewModel CreateScopeViewModel(ParsedScopeValue parsedScopeValue, ApiScope apiScope, bool check) { var displayName = apiScope.DisplayName ?? apiScope.Name; - if (!String.IsNullOrWhiteSpace(parsedScopeValue.ParsedParameter)) + if (!string.IsNullOrWhiteSpace(parsedScopeValue.ParsedParameter)) { displayName += ":" + parsedScopeValue.ParsedParameter; } diff --git a/src/Services/Identity/Identity.API/SeedData.cs b/src/Services/Identity/Identity.API/SeedData.cs index 1ce95871f..b8f5baa5b 100644 --- a/src/Services/Identity/Identity.API/SeedData.cs +++ b/src/Services/Identity/Identity.API/SeedData.cs @@ -1,4 +1,4 @@ -namespace Microsoft.eShopOnContainers.Services.Identity.API; +namespace Microsoft.eShopOnContainers.Services.Identity.API; public class SeedData { @@ -104,16 +104,7 @@ public class SeedData return Policy.Handle(). WaitAndRetryForeverAsync( sleepDurationProvider: retry => TimeSpan.FromSeconds(5), - onRetry: (exception, retry, timeSpan) => - { - logger.LogWarning( - exception, - "Exception {ExceptionType} with message {Message} detected during database migration (retry attempt {retry})", - exception.GetType().Name, - exception.Message, - retry); - } - ); + onRetry: (exception, retry, timeSpan) => logger.LogWarning(exception, "Error migrating database (retry attempt {retry})", retry)); } return Policy.NoOpAsync(); diff --git a/src/Services/Ordering/Ordering.API/Application/Behaviors/LoggingBehavior.cs b/src/Services/Ordering/Ordering.API/Application/Behaviors/LoggingBehavior.cs index 9ed7d1772..838697c8c 100644 --- a/src/Services/Ordering/Ordering.API/Application/Behaviors/LoggingBehavior.cs +++ b/src/Services/Ordering/Ordering.API/Application/Behaviors/LoggingBehavior.cs @@ -6,9 +6,9 @@ public class LoggingBehavior : IPipelineBehavior Handle(TRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { - _logger.LogInformation("----- Handling command {CommandName} ({@Command})", request.GetGenericTypeName(), request); + _logger.LogInformation("Handling command {CommandName} ({@Command})", request.GetGenericTypeName(), request); var response = await next(); - _logger.LogInformation("----- Command {CommandName} handled - response: {@Response}", request.GetGenericTypeName(), response); + _logger.LogInformation("Command {CommandName} handled - response: {@Response}", request.GetGenericTypeName(), response); return response; } diff --git a/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs b/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs index c27865a1e..acebd9cda 100644 --- a/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs +++ b/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs @@ -38,11 +38,11 @@ public class TransactionBehavior : IPipelineBehavior> { new ("TransactionContext", transaction.TransactionId) })) { - _logger.LogInformation("----- Begin transaction {TransactionId} for {CommandName} ({@Command})", transaction.TransactionId, typeName, request); + _logger.LogInformation("Begin transaction {TransactionId} for {CommandName} ({@Command})", transaction.TransactionId, typeName, request); response = await next(); - _logger.LogInformation("----- Commit transaction {TransactionId} for {CommandName}", transaction.TransactionId, typeName); + _logger.LogInformation("Commit transaction {TransactionId} for {CommandName}", transaction.TransactionId, typeName); await _dbContext.CommitTransactionAsync(transaction); @@ -56,7 +56,7 @@ public class TransactionBehavior : IPipelineBehavior : IPipelineBehavior v.Validate(request)) diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs index e445e5de1..b1b5be3dd 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommandHandler.cs @@ -44,7 +44,7 @@ public class CreateOrderCommandHandler order.AddOrderItem(item.ProductId, item.ProductName, item.UnitPrice, item.Discount, item.PictureUrl, item.Units); } - _logger.LogInformation("----- Creating Order - Order: {@Order}", order); + _logger.LogInformation("Creating Order - Order: {@Order}", order); _orderRepository.Add(order); diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs index 3864da446..0852bdc10 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs @@ -77,7 +77,7 @@ public abstract class IdentifiedCommandHandler : IRequestHandler : IRequestHandler> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); var command = new SetAwaitingValidationOrderStatusCommand(@event.OrderId); _logger.LogInformation( - "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", + "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", command.GetGenericTypeName(), nameof(command.OrderNumber), command.OrderNumber, diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs index 870d63d60..6982a5a25 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs @@ -18,12 +18,12 @@ public class OrderPaymentFailedIntegrationEventHandler : { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); var command = new CancelOrderCommand(@event.OrderId); _logger.LogInformation( - "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", + "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", command.GetGenericTypeName(), nameof(command.OrderNumber), command.OrderNumber, diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs index e1e6a9e86..31606ead2 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs @@ -18,12 +18,12 @@ public class OrderPaymentSucceededIntegrationEventHandler : { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); var command = new SetPaidOrderStatusCommand(@event.OrderId); _logger.LogInformation( - "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", + "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", command.GetGenericTypeName(), nameof(command.OrderNumber), command.OrderNumber, diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs index 68f2ec066..a9faea465 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs @@ -18,12 +18,12 @@ public class OrderStockConfirmedIntegrationEventHandler : { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); var command = new SetStockConfirmedOrderStatusCommand(@event.OrderId); _logger.LogInformation( - "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", + "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", command.GetGenericTypeName(), nameof(command.OrderNumber), command.OrderNumber, diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs index 4fa90ae0d..0d47e7a84 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs @@ -16,7 +16,7 @@ public class OrderStockRejectedIntegrationEventHandler : IIntegrationEventHandle { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); var orderStockRejectedItems = @event.OrderStockItems .FindAll(c => !c.HasStock) @@ -26,7 +26,7 @@ public class OrderStockRejectedIntegrationEventHandler : IIntegrationEventHandle var command = new SetStockRejectedOrderStatusCommand(@event.OrderId, orderStockRejectedItems); _logger.LogInformation( - "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", + "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", command.GetGenericTypeName(), nameof(command.OrderNumber), command.OrderNumber, diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs index d30ad98b5..731bc986f 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs @@ -26,7 +26,7 @@ public class UserCheckoutAcceptedIntegrationEventHandler : IIntegrationEventHand { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); var result = false; @@ -42,7 +42,7 @@ public class UserCheckoutAcceptedIntegrationEventHandler : IIntegrationEventHand var requestCreateOrder = new IdentifiedCommand(createOrderCommand, @event.RequestId); _logger.LogInformation( - "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", + "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", requestCreateOrder.GetGenericTypeName(), nameof(requestCreateOrder.Id), requestCreateOrder.Id, @@ -52,7 +52,7 @@ public class UserCheckoutAcceptedIntegrationEventHandler : IIntegrationEventHand if (result) { - _logger.LogInformation("----- CreateOrderCommand suceeded - RequestId: {RequestId}", @event.RequestId); + _logger.LogInformation("CreateOrderCommand suceeded - RequestId: {RequestId}", @event.RequestId); } else { diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs index a38179f5f..29e9a7ab4 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/OrderingIntegrationEventService.cs @@ -27,7 +27,7 @@ public class OrderingIntegrationEventService : IOrderingIntegrationEventService foreach (var logEvt in pendingLogEvents) { - _logger.LogInformation("----- Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", logEvt.EventId, logEvt.IntegrationEvent); + _logger.LogInformation("Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", logEvt.EventId, logEvt.IntegrationEvent); try { @@ -37,7 +37,7 @@ public class OrderingIntegrationEventService : IOrderingIntegrationEventService } catch (Exception ex) { - _logger.LogError(ex, "ERROR publishing integration event: {IntegrationEventId}", logEvt.EventId); + _logger.LogError(ex, "Error publishing integration event: {IntegrationEventId}", logEvt.EventId); await _eventLogService.MarkEventAsFailedAsync(logEvt.EventId); } @@ -46,7 +46,7 @@ public class OrderingIntegrationEventService : IOrderingIntegrationEventService public async Task AddAndSaveEventAsync(IntegrationEvent evt) { - _logger.LogInformation("----- Enqueuing integration event {IntegrationEventId} to repository ({@IntegrationEvent})", evt.Id, evt); + _logger.LogInformation("Enqueuing integration event {IntegrationEventId} to repository ({@IntegrationEvent})", evt.Id, evt); await _eventLogService.SaveEventAsync(evt, _orderingContext.GetCurrentTransaction()); } diff --git a/src/Services/Ordering/Ordering.API/Application/Validations/CancelOrderCommandValidator.cs b/src/Services/Ordering/Ordering.API/Application/Validations/CancelOrderCommandValidator.cs index 7d901b1fe..80fbcfcc4 100644 --- a/src/Services/Ordering/Ordering.API/Application/Validations/CancelOrderCommandValidator.cs +++ b/src/Services/Ordering/Ordering.API/Application/Validations/CancelOrderCommandValidator.cs @@ -6,6 +6,6 @@ public class CancelOrderCommandValidator : AbstractValidator { RuleFor(order => order.OrderNumber).NotEmpty().WithMessage("No orderId found"); - logger.LogTrace("----- INSTANCE CREATED - {ClassName}", GetType().Name); + logger.LogTrace("INSTANCE CREATED - {ClassName}", GetType().Name); } } diff --git a/src/Services/Ordering/Ordering.API/Application/Validations/CreateOrderCommandValidator.cs b/src/Services/Ordering/Ordering.API/Application/Validations/CreateOrderCommandValidator.cs index eb61082e7..51953b25d 100644 --- a/src/Services/Ordering/Ordering.API/Application/Validations/CreateOrderCommandValidator.cs +++ b/src/Services/Ordering/Ordering.API/Application/Validations/CreateOrderCommandValidator.cs @@ -18,7 +18,7 @@ public class CreateOrderCommandValidator : AbstractValidator RuleFor(command => command.CardTypeId).NotEmpty(); RuleFor(command => command.OrderItems).Must(ContainOrderItems).WithMessage("No order items found"); - logger.LogTrace("----- INSTANCE CREATED - {ClassName}", GetType().Name); + logger.LogTrace("INSTANCE CREATED - {ClassName}", GetType().Name); } private bool BeValidExpirationDate(DateTime dateTime) diff --git a/src/Services/Ordering/Ordering.API/Application/Validations/IdentifiedCommandValidator.cs b/src/Services/Ordering/Ordering.API/Application/Validations/IdentifiedCommandValidator.cs index bde2d771f..4d98fc14c 100644 --- a/src/Services/Ordering/Ordering.API/Application/Validations/IdentifiedCommandValidator.cs +++ b/src/Services/Ordering/Ordering.API/Application/Validations/IdentifiedCommandValidator.cs @@ -6,6 +6,6 @@ public class IdentifiedCommandValidator : AbstractValidator command.Id).NotEmpty(); - logger.LogTrace("----- INSTANCE CREATED - {ClassName}", GetType().Name); + logger.LogTrace("INSTANCE CREATED - {ClassName}", GetType().Name); } } diff --git a/src/Services/Ordering/Ordering.API/Application/Validations/ShipOrderCommandValidator.cs b/src/Services/Ordering/Ordering.API/Application/Validations/ShipOrderCommandValidator.cs index 0341c6028..dea55a4e3 100644 --- a/src/Services/Ordering/Ordering.API/Application/Validations/ShipOrderCommandValidator.cs +++ b/src/Services/Ordering/Ordering.API/Application/Validations/ShipOrderCommandValidator.cs @@ -6,6 +6,6 @@ public class ShipOrderCommandValidator : AbstractValidator { RuleFor(order => order.OrderNumber).NotEmpty().WithMessage("No orderId found"); - logger.LogTrace("----- INSTANCE CREATED - {ClassName}", GetType().Name); + logger.LogTrace("INSTANCE CREATED - {ClassName}", GetType().Name); } } diff --git a/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs b/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs index 2cfd4063f..5b9ca5f70 100644 --- a/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs +++ b/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs @@ -40,7 +40,7 @@ public class OrdersController : ControllerBase var requestCancelOrder = new IdentifiedCommand(command, guid); _logger.LogInformation( - "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", + "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", requestCancelOrder.GetGenericTypeName(), nameof(requestCancelOrder.Command.OrderNumber), requestCancelOrder.Command.OrderNumber, @@ -70,7 +70,7 @@ public class OrdersController : ControllerBase var requestShipOrder = new IdentifiedCommand(command, guid); _logger.LogInformation( - "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", + "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", requestShipOrder.GetGenericTypeName(), nameof(requestShipOrder.Command.OrderNumber), requestShipOrder.Command.OrderNumber, @@ -132,7 +132,7 @@ public class OrdersController : ControllerBase public async Task> CreateOrderDraftFromBasketDataAsync([FromBody] CreateOrderDraftCommand createOrderDraftCommand) { _logger.LogInformation( - "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", + "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", createOrderDraftCommand.GetGenericTypeName(), nameof(createOrderDraftCommand.BuyerId), createOrderDraftCommand.BuyerId, diff --git a/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs b/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs index 28f1a183d..23525d5bf 100644 --- a/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs +++ b/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs @@ -20,7 +20,7 @@ public class OrderingService : OrderingGrpc.OrderingGrpcBase { _logger.LogInformation("Begin grpc call from method {Method} for ordering get order draft {CreateOrderDraftCommand}", context.Method, createOrderDraftCommand); _logger.LogTrace( - "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", + "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", createOrderDraftCommand.GetGenericTypeName(), nameof(createOrderDraftCommand.BuyerId), createOrderDraftCommand.BuyerId, diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs index c392bb00d..d7f8663fd 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs @@ -59,7 +59,7 @@ public class OrderingContextSeed } catch (Exception ex) { - log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); + log.LogError(ex, "Error reading CSV headers"); return GetPredefinedCardTypes(); } @@ -67,13 +67,13 @@ public class OrderingContextSeed return File.ReadAllLines(csvFileCardTypes) .Skip(1) // skip header column .SelectTry(x => CreateCardType(x, ref id)) - .OnCaughtException(ex => { log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; }) + .OnCaughtException(ex => { log.LogError(ex, "Error creating card while seeding database"); return null; }) .Where(x => x != null); } private CardType CreateCardType(string value, ref int id) { - if (String.IsNullOrEmpty(value)) + if (string.IsNullOrEmpty(value)) { throw new Exception("Orderstatus is null or empty"); } @@ -103,7 +103,7 @@ public class OrderingContextSeed } catch (Exception ex) { - log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); + log.LogError(ex, "Error reading CSV headers"); return GetPredefinedOrderStatus(); } @@ -111,13 +111,13 @@ public class OrderingContextSeed return File.ReadAllLines(csvFileOrderStatus) .Skip(1) // skip header row .SelectTry(x => CreateOrderStatus(x, ref id)) - .OnCaughtException(ex => { log.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; }) + .OnCaughtException(ex => { log.LogError(ex, "Error creating order status while seeding database"); return null; }) .Where(x => x != null); } private OrderStatus CreateOrderStatus(string value, ref int id) { - if (String.IsNullOrEmpty(value)) + if (string.IsNullOrEmpty(value)) { throw new Exception("Orderstatus is null or empty"); } @@ -167,7 +167,7 @@ public class OrderingContextSeed sleepDurationProvider: retry => TimeSpan.FromSeconds(5), onRetry: (exception, timeSpan, retry, ctx) => { - logger.LogWarning(exception, "[{prefix}] Exception {ExceptionType} with message {Message} detected on attempt {retry} of {retries}", prefix, exception.GetType().Name, exception.Message, retry, retries); + logger.LogWarning(exception, "[{prefix}] Error seeding database (attempt {retry} of {retries})", prefix, retry, retries); } ); } diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs index a801ac831..bded89eb9 100644 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs +++ b/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs @@ -52,7 +52,7 @@ namespace Ordering.BackgroundTasks.Services { var confirmGracePeriodEvent = new GracePeriodConfirmedIntegrationEvent(orderId); - _logger.LogInformation("----- Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", confirmGracePeriodEvent.Id, confirmGracePeriodEvent); + _logger.LogInformation("Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", confirmGracePeriodEvent.Id, confirmGracePeriodEvent); _eventBus.Publish(confirmGracePeriodEvent); } @@ -74,7 +74,7 @@ namespace Ordering.BackgroundTasks.Services } catch (SqlException exception) { - _logger.LogCritical(exception, "FATAL ERROR: Database connections could not be opened: {Message}", exception.Message); + _logger.LogCritical(exception, "Fatal error establishing database connection"); } diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Address.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Address.cs index c58f81b16..0d4b819ae 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Address.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Address.cs @@ -4,11 +4,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O public class Address : ValueObject { - public String Street { get; private set; } - public String City { get; private set; } - public String State { get; private set; } - public String Country { get; private set; } - public String ZipCode { get; private set; } + public string Street { get; private set; } + public string City { get; private set; } + public string State { get; private set; } + public string Country { get; private set; } + public string ZipCode { get; private set; } public Address() { } diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderStatus.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderStatus.cs index aae09bc6a..8c3cc50fb 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderStatus.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/OrderStatus.cs @@ -23,11 +23,11 @@ public class OrderStatus public static OrderStatus FromName(string name) { var state = List() - .SingleOrDefault(s => String.Equals(s.Name, name, StringComparison.CurrentCultureIgnoreCase)); + .SingleOrDefault(s => string.Equals(s.Name, name, StringComparison.CurrentCultureIgnoreCase)); if (state == null) { - throw new OrderingDomainException($"Possible values for OrderStatus: {String.Join(",", List().Select(s => s.Name))}"); + throw new OrderingDomainException($"Possible values for OrderStatus: {string.Join(",", List().Select(s => s.Name))}"); } return state; @@ -39,7 +39,7 @@ public class OrderStatus if (state == null) { - throw new OrderingDomainException($"Possible values for OrderStatus: {String.Join(",", List().Select(s => s.Name))}"); + throw new OrderingDomainException($"Possible values for OrderStatus: {string.Join(",", List().Select(s => s.Name))}"); } return state; diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs index 9c460365c..4210830dc 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs @@ -18,7 +18,7 @@ public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler : IIn { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); await _hubContext.Clients .Group(@event.BuyerName) diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs index 1c3ea4623..d0642702a 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs @@ -20,7 +20,7 @@ public class OrderStatusChangedToCancelledIntegrationEventHandler : IIntegration { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); await _hubContext.Clients .Group(@event.BuyerName) diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs index fe66f7dbe..5b96fd7da 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs @@ -20,7 +20,7 @@ public class OrderStatusChangedToPaidIntegrationEventHandler : IIntegrationEvent { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); await _hubContext.Clients .Group(@event.BuyerName) diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs index 2f612bbfb..283c6f8a2 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs @@ -17,7 +17,7 @@ public class OrderStatusChangedToShippedIntegrationEventHandler : IIntegrationEv { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); await _hubContext.Clients .Group(@event.BuyerName) diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs index 7deb6c854..eea86552d 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs @@ -21,7 +21,7 @@ public class OrderStatusChangedToStockConfirmedIntegrationEventHandler : { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); await _hubContext.Clients .Group(@event.BuyerName) diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs index 0fa7ad8a5..7a536971c 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs @@ -21,7 +21,7 @@ public class OrderStatusChangedToSubmittedIntegrationEventHandler : { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); await _hubContext.Clients .Group(@event.BuyerName) diff --git a/src/Services/Ordering/Ordering.UnitTests/Application/OrdersWebApiTest.cs b/src/Services/Ordering/Ordering.UnitTests/Application/OrdersWebApiTest.cs index df6004e17..bb8f8844b 100644 --- a/src/Services/Ordering/Ordering.UnitTests/Application/OrdersWebApiTest.cs +++ b/src/Services/Ordering/Ordering.UnitTests/Application/OrdersWebApiTest.cs @@ -42,7 +42,7 @@ public class OrdersWebApiTest //Act var orderController = new OrdersController(_mediatorMock.Object, _orderQueriesMock.Object, _identityServiceMock.Object, _loggerMock.Object); - var actionResult = await orderController.CancelOrderAsync(new CancelOrderCommand(1), String.Empty) as BadRequestResult; + var actionResult = await orderController.CancelOrderAsync(new CancelOrderCommand(1), string.Empty) as BadRequestResult; //Assert Assert.Equal((int)System.Net.HttpStatusCode.BadRequest, actionResult.StatusCode); @@ -73,7 +73,7 @@ public class OrdersWebApiTest //Act var orderController = new OrdersController(_mediatorMock.Object, _orderQueriesMock.Object, _identityServiceMock.Object, _loggerMock.Object); - var actionResult = await orderController.ShipOrderAsync(new ShipOrderCommand(1), String.Empty) as BadRequestResult; + var actionResult = await orderController.ShipOrderAsync(new ShipOrderCommand(1), string.Empty) as BadRequestResult; //Assert Assert.Equal((int)System.Net.HttpStatusCode.BadRequest, actionResult.StatusCode); diff --git a/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs b/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs index d88bad3db..c68ab0959 100644 --- a/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs +++ b/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs @@ -25,7 +25,7 @@ public class OrderStatusChangedToStockConfirmedIntegrationEventHandler : { using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) { - _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); + _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); IntegrationEvent orderPaymentIntegrationEvent; @@ -44,7 +44,7 @@ public class OrderStatusChangedToStockConfirmedIntegrationEventHandler : orderPaymentIntegrationEvent = new OrderPaymentFailedIntegrationEvent(@event.OrderId); } - _logger.LogInformation("----- Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", orderPaymentIntegrationEvent.Id, orderPaymentIntegrationEvent); + _logger.LogInformation("Publishing integration event: {IntegrationEventId} - ({@IntegrationEvent})", orderPaymentIntegrationEvent.Id, orderPaymentIntegrationEvent); _eventBus.Publish(orderPaymentIntegrationEvent); diff --git a/src/Web/WebMVC/Controllers/AccountController.cs b/src/Web/WebMVC/Controllers/AccountController.cs index 9daf98275..f86a6e200 100644 --- a/src/Web/WebMVC/Controllers/AccountController.cs +++ b/src/Web/WebMVC/Controllers/AccountController.cs @@ -16,7 +16,7 @@ public class AccountController : Controller var user = User as ClaimsPrincipal; var token = await HttpContext.GetTokenAsync("access_token"); - _logger.LogInformation("----- User {@User} authenticated", user); + _logger.LogInformation("User {@User} authenticated", user); if (token != null) { diff --git a/src/Web/WebMVC/Extensions/HttpClientExtensions.cs b/src/Web/WebMVC/Extensions/HttpClientExtensions.cs index d1b11c9f7..3c95e0254 100644 --- a/src/Web/WebMVC/Extensions/HttpClientExtensions.cs +++ b/src/Web/WebMVC/Extensions/HttpClientExtensions.cs @@ -21,7 +21,7 @@ public class BasicAuthenticationHeaderValue : AuthenticationHeaderValue private static string EncodeCredential(string userName, string password) { Encoding encoding = Encoding.GetEncoding("iso-8859-1"); - string credential = String.Format("{0}:{1}", userName, password); + string credential = string.Format("{0}:{1}", userName, password); return Convert.ToBase64String(encoding.GetBytes(credential)); } diff --git a/src/Web/WebSPA/Server/Infrastructure/WebContextSeed.cs b/src/Web/WebSPA/Server/Infrastructure/WebContextSeed.cs index 1dc07b4f6..89f559873 100644 --- a/src/Web/WebSPA/Server/Infrastructure/WebContextSeed.cs +++ b/src/Web/WebSPA/Server/Infrastructure/WebContextSeed.cs @@ -51,13 +51,13 @@ public class WebContextSeed } else { - logger.LogWarning("Skipped file '{FileName}' in zipfile '{ZipFileName}'", entry.Name, imagesZipFile); + logger.LogWarning("Skipped file '{FileName}' in zip file '{ZipFileName}'", entry.Name, imagesZipFile); } } } catch (Exception ex) { - logger.LogError(ex, "ERROR in GetPreconfiguredImages: {Message}", ex.Message); + logger.LogError(ex, "Error getting preconfigured images"); } } }