Skip to content

Commit

Permalink
WebScaffold: add DumpLogEventsToConsole
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbarg committed Jan 24, 2025
1 parent ea8f303 commit c69c386
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/apps/Odin.Hosting.Tests/WebScaffold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,26 @@ public Dictionary<LogEventLevel, List<LogEvent>> GetLogEvents()
return logEvents;
}

public void DumpLogEventsToConsole()
{
Console.WriteLine("--------======== Log Events Begin ========--------");

var logEvents = new List<LogEvent>();
var keyedLogEvents = GetLogEvents();
foreach (var (level, events) in keyedLogEvents)
{
logEvents.AddRange(events);
}

logEvents.Sort((a,b) => a.Timestamp < b.Timestamp ? -1 : 1);
foreach (var logEvent in logEvents)
{
Console.WriteLine($"{logEvent.Timestamp.ToUnixTimeMilliseconds()} {logEvent.RenderMessage()}");
}

Console.WriteLine("--------======== Log Events End ========--------");
}

public void ClearLogEvents()
{
Services.GetRequiredService<ILogEventMemoryStore>().Clear();
Expand Down

0 comments on commit c69c386

Please sign in to comment.