diff --git a/EonaCat.Logger.LogServer/Controllers/LogsController.cs b/EonaCat.Logger.LogServer/Controllers/LogsController.cs index 02d412b..729cb0c 100644 --- a/EonaCat.Logger.LogServer/Controllers/LogsController.cs +++ b/EonaCat.Logger.LogServer/Controllers/LogsController.cs @@ -28,6 +28,7 @@ public class LogsController : ControllerBase return Unauthorized(new { error = "Invalid API key" }); } + await _logService.AddLogsAsync(entries); return Ok(new { success = true, count = entries.Count }); } @@ -48,9 +49,9 @@ public class LogsController : ControllerBase } [HttpGet("stats")] - public async Task GetStats([FromQuery] string? app, [FromQuery] string? env) + public async Task GetStats([FromQuery] string? app, [FromQuery] string? env, [FromQuery] bool skipCache = false) { - var stats = await _logService.GetStatsAsync(app, env); + var stats = await _logService.GetStatsAsync(app, env, skipCache); return Ok(stats); } diff --git a/EonaCat.Logger.LogServer/Data/LogDispatcher.cs b/EonaCat.Logger.LogServer/Data/LogDispatcher.cs new file mode 100644 index 0000000..48c4aa6 --- /dev/null +++ b/EonaCat.Logger.LogServer/Data/LogDispatcher.cs @@ -0,0 +1,31 @@ +using EonaCat.Logger.LogServer.Hubs; +using EonaCat.Logger.Server.Models; +using Microsoft.AspNetCore.SignalR; + +namespace EonaCat.Logger.LogServer.Data +{ + public class LogDispatcher + { + private readonly IHubContext _hub; + + public LogDispatcher(IHubContext hub) + { + _hub = hub; + } + + public async Task PublishAsync(LogEntry log) + { + await _hub.Clients.All.SendAsync("NewLog", new + { + id = log.Id, + level = log.Level, + message = log.Message, + applicationName = log.ApplicationName, + environment = log.Environment, + timestamp = log.Timestamp, + machineName = log.MachineName, + correlationId = log.CorrelationId + }); + } + } +} diff --git a/EonaCat.Logger.LogServer/EonaCat.Logger.LogServer.csproj b/EonaCat.Logger.LogServer/EonaCat.Logger.LogServer.csproj index 8875e6e..5c792e0 100644 --- a/EonaCat.Logger.LogServer/EonaCat.Logger.LogServer.csproj +++ b/EonaCat.Logger.LogServer/EonaCat.Logger.LogServer.csproj @@ -8,6 +8,7 @@ + all diff --git a/EonaCat.Logger.LogServer/Hubs/LogHub.cs b/EonaCat.Logger.LogServer/Hubs/LogHub.cs new file mode 100644 index 0000000..487b967 --- /dev/null +++ b/EonaCat.Logger.LogServer/Hubs/LogHub.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.SignalR; + +namespace EonaCat.Logger.LogServer.Hubs +{ + public class LogHub : Hub + { + public override async Task OnConnectedAsync() + { + await Clients.Caller.SendAsync("Connected", Context.ConnectionId); + await base.OnConnectedAsync(); + } + } +} diff --git a/EonaCat.Logger.LogServer/Pages/Index.cshtml b/EonaCat.Logger.LogServer/Pages/Index.cshtml index a801e5c..69c932c 100644 --- a/EonaCat.Logger.LogServer/Pages/Index.cshtml +++ b/EonaCat.Logger.LogServer/Pages/Index.cshtml @@ -356,6 +356,13 @@