summary refs log tree commit diff
path: root/LibSystemdCli/SystemdExecutor.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-01-20 09:19:14 +0100
committerRory& <root@rory.gay>2024-01-20 09:19:14 +0100
commit56ede8db6b1f90facbd3baa2599769f4e9f73013 (patch)
tree49d9c683bc99282e981725f4de91ab9be150ea30 /LibSystemdCli/SystemdExecutor.cs
parentInitial commit (diff)
downloadSystemdCtl-56ede8db6b1f90facbd3baa2599769f4e9f73013.tar.xz
Json logs
Diffstat (limited to 'LibSystemdCli/SystemdExecutor.cs')
-rw-r--r--LibSystemdCli/SystemdExecutor.cs7
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