Skip to content

Commit 77f1f4e

Browse files
committed
Ditch use of slogsyslog dependency
We don't need this; it's enough to just use slog's builtin plain text handler, which produces better formatted results for syslog anyway (instead of just a JSON dump of the log entry).
1 parent a090cdb commit 77f1f4e

3 files changed

Lines changed: 12 additions & 19 deletions

File tree

go.mod

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ go 1.21
44

55
require (
66
github.com/google/gopacket v1.1.19
7-
github.com/samber/slog-syslog/v2 v2.5.2
87
github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091
98
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
109
golang.org/x/sync v0.11.0
1110
)
1211

1312
require (
14-
github.com/samber/lo v1.47.0 // indirect
15-
github.com/samber/slog-common v0.18.1 // indirect
1613
golang.org/x/net v0.35.0 // indirect
1714
golang.org/x/sys v0.30.0 // indirect
18-
golang.org/x/text v0.22.0 // indirect
1915
)

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
22
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
3-
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
4-
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
5-
github.com/samber/slog-common v0.18.1 h1:c0EipD/nVY9HG5shgm/XAs67mgpWDMF+MmtptdJNCkQ=
6-
github.com/samber/slog-common v0.18.1/go.mod h1:QNZiNGKakvrfbJ2YglQXLCZauzkI9xZBjOhWFKS3IKk=
7-
github.com/samber/slog-syslog/v2 v2.5.2 h1:Z2gvh8asdPZ2O4hwCoMFbl7UchpgXwUjuY60s3uzK5U=
8-
github.com/samber/slog-syslog/v2 v2.5.2/go.mod h1:y4GGHr2Loc3bUcy4arWK9ds5b6rkekE5QUGRfUvq6zk=
93
github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091 h1:1zN6ImoqhSJhN8hGXFaJlSC8msLmIbX8bFqOfWLKw0w=
104
github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091/go.mod h1:N20Z5Y8oye9a7HmytmZ+tr8Q2vlP0tAHP13kTHzwvQY=
115
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 h1:TG/diQgUe0pntT/2D9tmUCz4VNwm9MfrtPr0SU2qSX8=
@@ -26,7 +20,5 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
2620
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
2721
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2822
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
29-
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
30-
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
3123
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
3224
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

logging/syslog.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ package logging
55
import (
66
"log/slog"
77
"log/syslog"
8-
9-
slogsyslog "github.com/samber/slog-syslog/v2"
108
)
119

1210
const (
@@ -31,9 +29,16 @@ func (syslogType) makeHandler(arg string) (slog.Handler, error) {
3129
return nil, err
3230
}
3331

34-
handler := slogsyslog.Option{
35-
Level: slog.LevelInfo,
36-
Writer: writer,
37-
}.NewSyslogHandler()
38-
return handler, nil
32+
// We use slog's built-in plain text handler to format the log
33+
// messages sent to syslog. The only thing we don't send is the
34+
// timestamp, since that's recorded by the syslogd anyway.
35+
return slog.NewTextHandler(writer, &slog.HandlerOptions{
36+
ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
37+
if a.Key == "time" {
38+
return slog.Attr{}
39+
} else {
40+
return a
41+
}
42+
},
43+
}), nil
3944
}

0 commit comments

Comments
 (0)