Skip to content

slog: only include for golang 1.21+ #2162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,4 @@ require (
modernc.org/token v1.1.0 // indirect
)

go 1.21
go 1.20
35 changes: 0 additions & 35 deletions go.sum

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions internal/log/slog.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build go1.21

package log

import (
Expand Down
2 changes: 2 additions & 0 deletions internal/log/slog_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build go1.21

package log

import (
Expand Down
15 changes: 15 additions & 0 deletions public/service/slog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//go:build go1.21

package service

import (
"log/slog"

"github.com/benthosdev/benthos/v4/internal/log"
)

// SetLogger sets a customer logger via Go's standard logging interface,
// allowing you to replace the default Benthos logger with your own.
func (s *StreamBuilder) SetLogger(l *slog.Logger) {
s.customLogger = log.NewBenthosLogAdapter(l)
}
7 changes: 0 additions & 7 deletions public/service/stream_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"log/slog"
"net/http"
"os"

Expand Down Expand Up @@ -126,12 +125,6 @@ func (s *StreamBuilder) SetPrintLogger(l PrintLogger) {
s.customLogger = log.Wrap(l)
}

// SetLogger sets a customer logger via Go's standard logging interface,
// allowing you to replace the default Benthos logger with your own.
func (s *StreamBuilder) SetLogger(l *slog.Logger) {
s.customLogger = log.NewBenthosLogAdapter(l)
}

// HTTPMultiplexer is an interface supported by most HTTP multiplexers.
type HTTPMultiplexer interface {
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
Expand Down