Files
Cleanuparr/code/Infrastructure/Logging/LogHub.cs
Flaminel a1bd278652 #21
2025-05-19 13:40:59 +03:00

28 lines
638 B
C#

using Microsoft.AspNetCore.SignalR;
namespace Infrastructure.Logging;
/// <summary>
/// SignalR hub for streaming log messages to connected clients
/// </summary>
public class LogHub : Hub
{
private readonly LogBuffer _logBuffer;
public LogHub(LogBuffer logBuffer)
{
_logBuffer = logBuffer;
}
/// <summary>
/// Allows a client to request all recent logs from the buffer
/// </summary>
public async Task RequestRecentLogs()
{
foreach (var logEvent in _logBuffer.GetRecentLogs())
{
await Clients.Caller.SendAsync("ReceiveLog", logEvent);
}
}
}