summaryrefslogtreecommitdiffstats
path: root/src/go/logger/journal_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/logger/journal_linux.go')
-rw-r--r--src/go/logger/journal_linux.go25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/go/logger/journal_linux.go b/src/go/logger/journal_linux.go
index 00f335075..f55006bdb 100644
--- a/src/go/logger/journal_linux.go
+++ b/src/go/logger/journal_linux.go
@@ -5,29 +5,10 @@
package logger
import (
- "os"
- "strconv"
- "strings"
- "syscall"
+ "github.com/coreos/go-systemd/v22/journal"
)
func isStderrConnectedToJournal() bool {
- stream := os.Getenv("JOURNAL_STREAM")
- if stream == "" {
- return false
- }
-
- idx := strings.IndexByte(stream, ':')
- if idx <= 0 {
- return false
- }
-
- dev, ino := stream[:idx], stream[idx+1:]
-
- var stat syscall.Stat_t
- if err := syscall.Fstat(int(os.Stderr.Fd()), &stat); err != nil {
- return false
- }
-
- return dev == strconv.Itoa(int(stat.Dev)) && ino == strconv.FormatUint(stat.Ino, 10)
+ ok, _ := journal.StderrIsJournalStream()
+ return ok
}