diff options
author | Rory& <root@rory.gay> | 2024-01-20 09:19:14 +0100 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-01-20 09:19:14 +0100 |
commit | 56ede8db6b1f90facbd3baa2599769f4e9f73013 (patch) | |
tree | 49d9c683bc99282e981725f4de91ab9be150ea30 /SystemdCtl | |
parent | Initial commit (diff) | |
download | SystemdCtl-56ede8db6b1f90facbd3baa2599769f4e9f73013.tar.xz |
Json logs
Diffstat (limited to '')
-rw-r--r-- | SystemdCtl.Client/Pages/ServiceManage.razor | 4 | ||||
-rw-r--r-- | SystemdCtl/Controllers/UnitController.cs | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/SystemdCtl.Client/Pages/ServiceManage.razor b/SystemdCtl.Client/Pages/ServiceManage.razor index 9a32087..c622833 100644 --- a/SystemdCtl.Client/Pages/ServiceManage.razor +++ b/SystemdCtl.Client/Pages/ServiceManage.razor @@ -35,7 +35,7 @@ private static bool IsClient => !Environment.CommandLine.Contains("/"); - private List<string> LogLines { get; set; } = new(); + private List<SystemdJournalLogItem> LogLines { get; set; } = new(); protected override async Task OnInitializedAsync() { Console.WriteLine("OnInitializedAsync"); @@ -47,7 +47,7 @@ LogLines.Clear(); var Http = new StreamingHttpClient() { BaseAddress = new Uri(NavigationManager.BaseUri) }; - var _items = Http.GetAsyncEnumerableFromJsonAsync<string>($"/api/unit/{ServiceName}/logs"); + var _items = Http.GetAsyncEnumerableFromJsonAsync<SystemdJournalLogItem>($"/api/unit/{ServiceName}/logs"); await foreach (var item in _items) { LogLines.Add(item); if (LogLines.Count > 100) LogLines.RemoveAt(0); diff --git a/SystemdCtl/Controllers/UnitController.cs b/SystemdCtl/Controllers/UnitController.cs index 212df7d..00916bf 100644 --- a/SystemdCtl/Controllers/UnitController.cs +++ b/SystemdCtl/Controllers/UnitController.cs @@ -18,11 +18,11 @@ public class UnitController : ControllerBase } [HttpGet("unit/{serviceName}/logs")] - public async IAsyncEnumerable<string> GetUnitLogs(string serviceName) + public async IAsyncEnumerable<SystemdJournalLogItem> GetUnitLogs(string serviceName) { - await foreach (var line in CommandExecutor.ExecuteCommandAsync("journalctl", $"-xaefu {serviceName}")) + await foreach (var log in SystemdExecutor.GetUnitLogs(serviceName)) { - yield return line; + yield return log; await Response.Body.FlushAsync(); } } |