From 5f1870f32f0854d7a57cf51dd97492878e60bd80 Mon Sep 17 00:00:00 2001 From: Casper Sparre Date: Tue, 14 Oct 2025 00:50:22 +0200 Subject: [PATCH] More logging tweaks --- OF DL/Program.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OF DL/Program.cs b/OF DL/Program.cs index dc40a14..9fbac16 100644 --- a/OF DL/Program.cs +++ b/OF DL/Program.cs @@ -117,7 +117,7 @@ public class Program .Enrich.WithProperty("StartTime", $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ") .Enrich.WithProperty("MachineName", Environment.MachineName) .MinimumLevel.ControlledBy(levelSwitch) - .WriteTo.File("logs/OFDL.txt", rollingInterval: RollingInterval.Day) + .WriteTo.File("logs/OFDL.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Error) .WriteTo.Seq("https://seq.cajetan.dk") .CreateLogger(); @@ -986,10 +986,12 @@ public class Program using (LogContext.PushProperty("Username", username)) using (LogContext.PushProperty("UserId", userId)) + using (LogContext.PushProperty("UserNum", prevValue+1)) + using (LogContext.PushProperty("UserTotal", users.Count)) { try { - Log.Information("Updating User Info for for: {Username:l}"); + Log.Information("[{UserNum:0} of {UserTotal}] Updating User Info for for: {Username:l}"); User? user_info = await m_ApiHelper.GetUserInfo(username, $"/users/{username}"); await dbHelper.UpdateUserInfo(username, user_info); @@ -997,7 +999,7 @@ public class Program } catch (Exception ex) { - Log.Warning(ex, "Failed to update User Info for: {Username:l}"); + Log.Warning(ex, "[{UserNum:0} of {UserTotal}] Failed to update User Info for: {Username:l}"); AnsiConsole.Markup($"[red]Failed to update User Info for '{username}'\n[/]"); updateTask.Description = $"{description} - FAILED: {ex.Message}";