34 lines
676 B
Go
34 lines
676 B
Go
package logger
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log/slog"
|
|
)
|
|
|
|
type logger struct {
|
|
log *slog.Logger
|
|
}
|
|
|
|
func (l *logger) Debug(ctx context.Context, msg string, args ...any) {
|
|
l.log.DebugContext(ctx, fmt.Sprintf(msg, args...))
|
|
}
|
|
|
|
func (l *logger) Info(ctx context.Context, msg string, args ...any) {
|
|
l.log.InfoContext(ctx, fmt.Sprintf(msg, args...))
|
|
}
|
|
|
|
func (l *logger) Warn(ctx context.Context, msg string, args ...any) {
|
|
l.log.WarnContext(ctx, fmt.Sprintf(msg, args...))
|
|
}
|
|
|
|
func (l *logger) Error(ctx context.Context, msg string, args ...any) {
|
|
l.log.ErrorContext(ctx, fmt.Sprintf(msg, args...))
|
|
}
|
|
|
|
func NewLogger(log *slog.Logger) Logger {
|
|
return &logger{
|
|
log: log,
|
|
}
|
|
}
|