spf13--viper/logger.go
Mark Sagi-Kazar 7162e9244e refactor!: drop unused Logger interface
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
2024-06-02 11:53:32 +02:00

31 lines
544 B
Go

package viper
import (
"context"
"log/slog"
)
// WithLogger sets a custom logger.
func WithLogger(l *slog.Logger) Option {
return optionFunc(func(v *Viper) {
v.logger = l
})
}
type discardHandler struct{}
func (n *discardHandler) Enabled(_ context.Context, _ slog.Level) bool {
return false
}
func (n *discardHandler) Handle(_ context.Context, _ slog.Record) error {
return nil
}
func (n *discardHandler) WithAttrs(_ []slog.Attr) slog.Handler {
return n
}
func (n *discardHandler) WithGroup(_ string) slog.Handler {
return n
}