Commit 718d479a authored by Oleksandr Redko's avatar Oleksandr Redko Committed by Timo Furrer
Browse files

chore(no-release): refactor to slog.DiscardHandler

Changelog: Improvements
parent ca0d7b7b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ linters:
    - nakedret
    - nolintlint
    - revive
    - sloglint
    - staticcheck
    - testifylint
    - unconvert
+2 −3
Original line number Diff line number Diff line
@@ -153,12 +153,11 @@ func WithUserAgent(userAgent string) ClientOptionFunc {

// WithURLWarningLogger sets a custom logger for URL validation warnings.
// By default, warnings are logged using slog.Default().
// Pass slog.New(slog.NewTextHandler(io.Discard, nil)) to disable warnings.
// TODO: Use slog.NewDiscardHandler() when we upgrade to Go 1.25+
// Pass slog.New(slog.DiscardHandler) to disable warnings.
func WithURLWarningLogger(logger *slog.Logger) ClientOptionFunc {
	return func(c *Client) error {
		if logger == nil {
			return errors.New("logger cannot be nil, use slog.New(slog.NewTextHandler(io.Discard, nil)) to discard warnings")
			return errors.New("logger cannot be nil, use slog.New(slog.DiscardHandler) to discard warnings")
		}
		c.urlWarningLogger = logger
		return nil
+1 −2
Original line number Diff line number Diff line
@@ -1614,8 +1614,7 @@ func TestSetBaseURL_ValidationWarnings(t *testing.T) {
			t.Parallel()

			c := &Client{
				// TODO: Use slog.NewDiscardHandler() when we upgrade to Go 1.25+
				urlWarningLogger: slog.New(slog.NewTextHandler(io.Discard, nil)),
				urlWarningLogger: slog.New(slog.DiscardHandler),
			}

			err := c.setBaseURL(tt.input)