Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
rename helper handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyam8 committed Nov 15, 2023
1 parent ad10b7b commit 8cf0589
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions logger/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func newBaseLogger() *Logger {

func newTerminalLogger() *Logger {
src := Level.Level() == slog.LevelDebug
h := &handler{
h := &callDepthHandler{
src: src,
sh: tint.NewHandler(os.Stderr, &tint.Options{
AddSource: src,
Expand All @@ -50,24 +50,24 @@ func newLogger() *Logger {
return &Logger{sl: slog.New(h)}
}

type handler struct {
type callDepthHandler struct {
src bool
sh slog.Handler
}

func (h *handler) Enabled(ctx context.Context, level slog.Level) bool {
func (h *callDepthHandler) Enabled(ctx context.Context, level slog.Level) bool {
return h.sh.Enabled(ctx, level)
}

func (h *handler) WithAttrs(attrs []slog.Attr) slog.Handler {
return &handler{src: h.src, sh: h.sh.WithAttrs(attrs)}
func (h *callDepthHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
return &callDepthHandler{src: h.src, sh: h.sh.WithAttrs(attrs)}
}

func (h *handler) WithGroup(name string) slog.Handler {
return &handler{src: h.src, sh: h.sh.WithGroup(name)}
func (h *callDepthHandler) WithGroup(name string) slog.Handler {
return &callDepthHandler{src: h.src, sh: h.sh.WithGroup(name)}
}

func (h *handler) Handle(ctx context.Context, r slog.Record) error {
func (h *callDepthHandler) Handle(ctx context.Context, r slog.Record) error {
if h.src {
// https://pkg.go.dev/log/slog#example-package-Wrapping
var pcs [1]uintptr
Expand Down

0 comments on commit 8cf0589

Please sign in to comment.