From 111ec55d9ea00e033b6ea449b77a3c3782f68b90 Mon Sep 17 00:00:00 2001 From: Scott Kirkland Date: Fri, 19 Jan 2024 13:19:03 -0800 Subject: [PATCH 1/2] don't show full EF logs of every query --- Sloth.Api/Logging/LoggingConfiguration.cs | 2 +- Sloth.Jobs.Core/Logging/LoggingConfiguration.cs | 2 +- Sloth.Web/Logging/LoggingConfiguration.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sloth.Api/Logging/LoggingConfiguration.cs b/Sloth.Api/Logging/LoggingConfiguration.cs index 234d7bac..0fcb2848 100644 --- a/Sloth.Api/Logging/LoggingConfiguration.cs +++ b/Sloth.Api/Logging/LoggingConfiguration.cs @@ -46,7 +46,7 @@ public static LoggerConfiguration GetConfiguration() // standard logger var logConfig = new LoggerConfiguration() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - // .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) // uncomment this to hide EF core general info logs + .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) // uncomment this to hide EF core general info logs .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning) .Enrich.FromLogContext() .Enrich.WithExceptionDetails() diff --git a/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs b/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs index 92de6c30..f617e04d 100644 --- a/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs +++ b/Sloth.Jobs.Core/Logging/LoggingConfiguration.cs @@ -51,7 +51,7 @@ public static LoggerConfiguration GetConfiguration() // standard logger var logConfig = new LoggerConfiguration() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - // .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) // uncomment this to hide EF core general info logs + .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) // uncomment this to hide EF core general info logs .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning) .Enrich.FromLogContext() .Enrich.WithExceptionDetails() diff --git a/Sloth.Web/Logging/LoggingConfiguration.cs b/Sloth.Web/Logging/LoggingConfiguration.cs index fa67440f..003bf1be 100644 --- a/Sloth.Web/Logging/LoggingConfiguration.cs +++ b/Sloth.Web/Logging/LoggingConfiguration.cs @@ -45,7 +45,7 @@ public static LoggerConfiguration GetConfiguration() // standard logger var logConfig = new LoggerConfiguration() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) - // .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) // uncomment this to hide EF core general info logs + .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) // uncomment this to hide EF core general info logs .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning) .Enrich.FromLogContext() .Enrich.WithExceptionDetails() From 3bfc2066c5d96276ee48db9c7303c761ccdad706 Mon Sep 17 00:00:00 2001 From: Scott Kirkland Date: Fri, 19 Jan 2024 13:19:20 -0800 Subject: [PATCH 2/2] log basic txn info on start of txn POST --- .../Controllers/v2/TransactionsController.cs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Sloth.Api/Controllers/v2/TransactionsController.cs b/Sloth.Api/Controllers/v2/TransactionsController.cs index 23d8bd40..84e4b3b8 100644 --- a/Sloth.Api/Controllers/v2/TransactionsController.cs +++ b/Sloth.Api/Controllers/v2/TransactionsController.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage; +using Serilog; using Sloth.Api.Attributes; using Sloth.Api.Errors; using Sloth.Api.Models.v2; @@ -185,8 +186,6 @@ public async Task> GetByMetadata(string key, string value) return transactions; } - // TODO: just for testing, remove later - /// /// Validate Financial Segment String /// @@ -199,9 +198,6 @@ public async Task ValidateFinancialSegmentString(string id) return await _aggieEnterpriseService.IsAccountValid(id); } - - // TODO: update to AE - /// /// Create a Transaction with a list of Transfers /// @@ -212,6 +208,8 @@ public async Task ValidateFinancialSegmentString(string id) [ProducesResponseType(typeof(BadRequestObjectResult), 400)] public async Task Post([FromBody] CreateTransactionViewModel transaction) { + LogTransactionCreating(transaction); + var teamId = GetTeamId(); if (!ModelState.IsValid) @@ -364,6 +362,23 @@ await _context.Database.CreateExecutionStrategy().ExecuteAsync(async () => return new JsonResult(transactionToCreate); } + private void LogTransactionCreating(CreateTransactionViewModel transaction) + { + var txn = new + { + transaction.KfsTrackingNumber, + transaction.ProcessorTrackingNumber, + transaction.MerchantTrackingNumber, + transaction.MerchantTrackingUrl, + transaction.Source, + transaction.SourceType, + Transfers = transaction.Transfers.Select(t => new { t.Amount, t.FinancialSegmentString, t.Description, t.Direction }).ToArray(), + Metadata = transaction.Metadata.Select(m => new { m.Name, m.Value }).ToArray(), + }; + + Log.Information("Transaction Creation Starting: {@Transaction}", txn); + } + private string GetTeamId() { return User.FindFirst(ClaimTypes.PrimaryGroupSid)?.Value;