Fix systemd logs retrieval

This commit is contained in:
sfigato 2023-03-14 00:02:39 +01:00
parent 79a2c8aa66
commit c843eebdd7
Signed by: blallo
GPG Key ID: C530464EEDCF489A

View File

@ -119,11 +119,16 @@ func (u *SystemdUnit) Stop(ctx context.Context) error {
} }
func (u *SystemdUnit) Logs(context.Context) []string { func (u *SystemdUnit) Logs(context.Context) []string {
field := sdjournal.SD_JOURNAL_FIELD_SYSTEMD_UNIT
if u.user {
field = sdjournal.SD_JOURNAL_FIELD_SYSTEMD_USER_UNIT
}
journal, err := sdjournal.NewJournalReader(sdjournal.JournalReaderConfig{ journal, err := sdjournal.NewJournalReader(sdjournal.JournalReaderConfig{
NumFromTail: bufLines, NumFromTail: bufLines,
Matches: []sdjournal.Match{ Matches: []sdjournal.Match{
{ {
Field: sdjournal.SD_JOURNAL_FIELD_SYSTEMD_UNIT, Field: field,
Value: u.unit, Value: u.unit,
}, },
}, },