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 /LibSystemdCli/SystemdExecutor.cs | |
parent | Initial commit (diff) | |
download | SystemdCtl-56ede8db6b1f90facbd3baa2599769f4e9f73013.tar.xz |
Json logs
Diffstat (limited to 'LibSystemdCli/SystemdExecutor.cs')
-rw-r--r-- | LibSystemdCli/SystemdExecutor.cs | 7 |
1 files changed, 7 insertions, 0 deletions
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<SystemdJournalLogItem> GetUnitLogs(string serviceName) { + await foreach (var line in CommandExecutor.ExecuteCommandAsync("journalctl", $"--catalog --all --pager-end --follow --output=json --unit={serviceName}")) + { + yield return JsonSerializer.Deserialize<SystemdJournalLogItem>(line)!; + } + } } \ No newline at end of file |