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