diff options
Diffstat (limited to 'LibSystemdCli')
-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 |