2021-12-09 17:34:40 +00:00
|
|
|
package viper
|
|
|
|
|
|
|
|
import (
|
2023-09-11 22:03:41 +00:00
|
|
|
"context"
|
2024-06-02 09:44:09 +00:00
|
|
|
"log/slog"
|
2021-12-09 17:34:40 +00:00
|
|
|
)
|
|
|
|
|
2023-09-11 22:03:41 +00:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2023-09-11 22:53:34 +00:00
|
|
|
func (n *discardHandler) WithAttrs(_ []slog.Attr) slog.Handler {
|
2023-09-11 22:03:41 +00:00
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
2023-09-11 22:53:34 +00:00
|
|
|
func (n *discardHandler) WithGroup(_ string) slog.Handler {
|
2023-09-11 22:03:41 +00:00
|
|
|
return n
|
|
|
|
}
|