diff --git a/go.mod b/go.mod index f59de9eec..8ca701ffa 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,6 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.23.2 github.com/rs/xid v1.6.0 - github.com/sirupsen/logrus v1.9.3 github.com/slackhq/nebula v1.9.7 github.com/smallstep/assert v0.0.0-20200723003110-82e2b9b3b262 github.com/smallstep/cli-utils v0.12.2 diff --git a/go.sum b/go.sum index 12f10214c..1fa53c2a6 100644 --- a/go.sum +++ b/go.sum @@ -475,7 +475,6 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/logging/clf.go b/logging/clf.go index 0e4d9ae9b..d2e53109d 100644 --- a/logging/clf.go +++ b/logging/clf.go @@ -2,31 +2,47 @@ package logging import ( "bytes" + "context" "fmt" + "io" + "log/slog" "strconv" "time" - - "github.com/sirupsen/logrus" ) var clfFields = [...]string{ "request-id", "remote-address", "name", "user-id", "time", "duration", "method", "path", "protocol", "status", "size", } -// CommonLogFormat implements the logrus.Formatter interface it writes logrus +// CommonLogFormat implements the slog.Handler interface it writes slog // entries using a CLF format prepended by the request-id. -type CommonLogFormat struct{} +type CommonLogFormat struct { + output io.Writer +} + +// Enabled implements the slog.Handler interface. +func (f *CommonLogFormat) Enabled(ctx context.Context, level slog.Level) bool { + return true +} -// Format implements the logrus.Formatter interface. It returns the given -// logrus entry as a CLF line with the following format: +// Handle implements the slog.Handler interface. It returns the given +// slog record as a CLF line with the following format: // //