More logging tweaks

This commit is contained in:
Casper Sparre 2025-10-14 00:50:22 +02:00
parent f40bd0527b
commit 0cfac356c5

View File

@ -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}";