From cf71555cb956a96c6c6b3e7d79bcfbfbf9f7956e Mon Sep 17 00:00:00 2001 From: John Lambert Date: Thu, 12 Sep 2024 13:19:14 -0400 Subject: [PATCH] Be explicit about engineId in every log (#490) Only log 500 codes --- .../src/Serval.Shared/Controllers/ErrorResultFilter.cs | 2 +- .../Controllers/TranslationEnginesController.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Serval/src/Serval.Shared/Controllers/ErrorResultFilter.cs b/src/Serval/src/Serval.Shared/Controllers/ErrorResultFilter.cs index ab8e3903..78ed4711 100644 --- a/src/Serval/src/Serval.Shared/Controllers/ErrorResultFilter.cs +++ b/src/Serval/src/Serval.Shared/Controllers/ErrorResultFilter.cs @@ -7,7 +7,7 @@ public class ErrorResultFilter(ILoggerFactory loggerFactory) : IAlwaysRunResultF public void OnResultExecuted(ResultExecutedContext context) { - if (context.HttpContext.Response.StatusCode >= 400) + if (context.HttpContext.Response.StatusCode >= 500) { _logger.LogInformation( "Client {client} made request:\n {request}.\n Serval responded with code {statusCode}. Trace: {activityId}", diff --git a/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs b/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs index 052d7ede..31d69846 100644 --- a/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs +++ b/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs @@ -704,7 +704,12 @@ CancellationToken cancellationToken ); if (usfm == "") return NoContent(); - _logger.LogInformation("Returning USFM for {TextId} in {CorpusId} of {EngineId}", textId, corpusId, id); + _logger.LogInformation( + "Returning USFM for {TextId} in engine {EngineId} for corpus {corpusId}", + textId, + id, + corpusId + ); return Content(usfm, "text/plain"); }