Integrate NLog for centralized logging, replacing Console calls across CLI tasks. Add LoggingService helper for setup and logger retrieval. Update project dependencies.

This commit is contained in:
Andre Beging
2025-12-12 09:29:31 +01:00
parent c9a56abe8b
commit 516fceb1dc
7 changed files with 102 additions and 28 deletions

View File

@@ -1,11 +1,14 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using FsToolbox.Cli.Helper;
using NLog;
namespace FsToolbox.Cli.Tasks
{
public static partial class RegionTasks
{
private static readonly Logger Logger = LoggingService.GetLogger(nameof(RegionTasks));
#region Public Method GetStoresInRegionAsync
/// <summary>
@@ -25,12 +28,12 @@ namespace FsToolbox.Cli.Tasks
// handle unsuccessful response
if (!response.IsSuccessStatusCode)
{
await Console.Error.WriteLineAsync($"Region stores retrieval failed ({(int)response.StatusCode} {response.ReasonPhrase}): {responseBody}");
Logger.Error("Region stores retrieval failed ({Status} {Reason}): {Body}", (int)response.StatusCode, response.ReasonPhrase, responseBody);
return [];
}
Console.WriteLine($"Stores in region {regionId}:");
Console.WriteLine(responseBody);
Logger.Info("Stores in region {RegionId}:", regionId);
Logger.Info(responseBody);
var root = JsonNode.Parse(responseBody);
if (root == null) return [];