diff --git a/systemd.go b/systemd.go index c6a43dc..3d62d1b 100644 --- a/systemd.go +++ b/systemd.go @@ -119,11 +119,16 @@ func (u *SystemdUnit) Stop(ctx context.Context) error { } 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{ NumFromTail: bufLines, Matches: []sdjournal.Match{ { - Field: sdjournal.SD_JOURNAL_FIELD_SYSTEMD_UNIT, + Field: field, Value: u.unit, }, },