Skip to content

Commit 5e707dd

Browse files
committed
add SYSLOG_IDENTIFIER
1 parent 6fc9638 commit 5e707dd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

journal.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"encoding/binary"
77
"io"
88
"log/slog"
9+
"os"
10+
"path"
911
"runtime"
1012
"slices"
1113
"strconv"
@@ -99,6 +101,8 @@ func (h *Handler) Enabled(_ context.Context, level slog.Level) bool {
99101
return level >= h.opts.Level.Level()
100102
}
101103

104+
var identifier = []byte(path.Base(os.Args[0]))
105+
102106
// Handle handles the Record.
103107
// It will only be called when Enabled returns true.
104108
// The Context argument is as for Enabled.
@@ -137,6 +141,8 @@ func (h *Handler) Handle(ctx context.Context, r slog.Record) error {
137141
buf = h.appendKV(buf, "SYSLOG_TIMESTAMP", []byte(timestampStr))
138142
}
139143

144+
buf = h.appendKV(buf, "SYSLOG_IDENTIFIER", identifier)
145+
140146
buf = append(buf, h.preformatted...)
141147

142148
r.Attrs(func(a slog.Attr) bool {

0 commit comments

Comments
 (0)