Skip to content

Commit

Permalink
More updates for logging:
Browse files Browse the repository at this point in the history
* Ignore all the HttpClient requests to the world
* Log each time a translation (or similar) is requested.
  • Loading branch information
johnml1135 committed Sep 10, 2024
1 parent a5fbe96 commit efa70ff
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/Echo/src/EchoTranslationEngine/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft.AspNetCore": "Warning",
"System.Net.Http.HttpClient": "Warning"
}
},
"AllowedHosts": "*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"System.Net.Http.HttpClient.Default": "Warning"
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"Logging": {
"LogLevel": {
"System.Net.Http.HttpClient.Default": "Warning"
"System.Net.Http.HttpClient": "Warning"
}
}
}
2 changes: 1 addition & 1 deletion src/Machine/src/Serval.Machine.JobServer/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"Logging": {
"LogLevel": {
"System.Net.Http.HttpClient.Default": "Warning"
"System.Net.Http.HttpClient": "Warning"
}
}
}
5 changes: 5 additions & 0 deletions src/Serval/src/Serval.ApiServer/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@
},
"DataFile": {
"FilesDirectory": "/var/lib/serval/files"
},
"Logging": {
"LogLevel": {
"System.Net.Http.HttpClient": "Warning"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public class TranslationEnginesController(
IBuildService buildService,
IPretranslationService pretranslationService,
IOptionsMonitor<ApiOptions> apiOptions,
IUrlService urlService
IUrlService urlService,
ILogger<TranslationEnginesController> logger
) : ServalControllerBase(authService)
{
private static readonly JsonSerializerOptions ObjectJsonSerializerOptions =
Expand All @@ -20,6 +21,7 @@ IUrlService urlService
private readonly IPretranslationService _pretranslationService = pretranslationService;
private readonly IOptionsMonitor<ApiOptions> _apiOptions = apiOptions;
private readonly IUrlService _urlService = urlService;
private readonly ILogger<TranslationEnginesController> _logger = logger;

/// <summary>
/// Get all translation engines
Expand Down Expand Up @@ -185,6 +187,7 @@ CancellationToken cancellationToken
{
await AuthorizeAsync(id, cancellationToken);
TranslationResult result = await _engineService.TranslateAsync(id, segment, cancellationToken);
_logger.LogInformation("Translated segment for engine {EngineId}", id);
return Ok(Map(result));
}

Expand Down Expand Up @@ -222,6 +225,7 @@ CancellationToken cancellationToken
{
await AuthorizeAsync(id, cancellationToken);
IEnumerable<TranslationResult> results = await _engineService.TranslateAsync(id, n, segment, cancellationToken);
_logger.LogInformation("Translated {n} segments for engine {EngineId}", n, id);
return Ok(results.Select(Map));
}

Expand Down Expand Up @@ -257,6 +261,7 @@ CancellationToken cancellationToken
{
await AuthorizeAsync(id, cancellationToken);
WordGraph wordGraph = await _engineService.GetWordGraphAsync(id, segment, cancellationToken);
_logger.LogInformation("Got word graph for engine {EngineId}", id);
return Ok(Map(wordGraph));
}

Expand Down Expand Up @@ -303,6 +308,7 @@ await _engineService.TrainSegmentPairAsync(
segmentPair.SentenceStart,
cancellationToken
);
_logger.LogInformation("Trained segment pair for engine {EngineId}", id);
return Ok();
}

Expand Down Expand Up @@ -557,6 +563,13 @@ CancellationToken cancellationToken
textId,
cancellationToken
);
_logger.LogInformation(
"Returning {Count} pretranslations for engine {EngineId}, corpus {CorpusId}, and query {TextId}",
pretranslations.Count(),
id,
corpusId,
textId
);
return Ok(pretranslations.Select(Map));
}

Expand Down Expand Up @@ -612,6 +625,13 @@ CancellationToken cancellationToken
textId,
cancellationToken
);
_logger.LogInformation(
"Returning {Count} pretranslations for engine {EngineId}, corpus {CorpusId}, and textId {TextId}",
pretranslations.Count(),
id,
corpusId,
textId
);
return Ok(pretranslations.Select(Map));
}

Expand Down Expand Up @@ -684,6 +704,7 @@ CancellationToken cancellationToken
);
if (usfm == "")
return NoContent();
_logger.LogInformation("Returning USFM for {TextId} in {CorpusId} of {EngineId}", textId, corpusId, id);
return Content(usfm, "text/plain");
}

Expand Down

0 comments on commit efa70ff

Please sign in to comment.