From 56ede8db6b1f90facbd3baa2599769f4e9f73013 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sat, 20 Jan 2024 09:19:14 +0100 Subject: Json logs --- LibSystemdCli/SystemdExecutor.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'LibSystemdCli') diff --git a/LibSystemdCli/SystemdExecutor.cs b/LibSystemdCli/SystemdExecutor.cs index eb6dfc9..06c9538 100644 --- a/LibSystemdCli/SystemdExecutor.cs +++ b/LibSystemdCli/SystemdExecutor.cs @@ -28,4 +28,11 @@ public class SystemdExecutor // await Task.Delay(100); } } + + public static async IAsyncEnumerable GetUnitLogs(string serviceName) { + await foreach (var line in CommandExecutor.ExecuteCommandAsync("journalctl", $"--catalog --all --pager-end --follow --output=json --unit={serviceName}")) + { + yield return JsonSerializer.Deserialize(line)!; + } + } } \ No newline at end of file -- cgit 1.4.1