...
1
2
3
4
5
6
7 package slog
8
9 import (
10 "context"
11 "log"
12
13 "golang.org/x/exp/slog"
14 )
15
16
17 func Default() *Logger { return slog.Default() }
18
19
20
21
22 func SetDefault(l *Logger) {
23 slog.SetDefault(l)
24 }
25
26
27
28
29
30
31
32 type Logger = slog.Logger
33
34
35 func New(h Handler) *Logger {
36 return slog.New(h)
37 }
38
39
40 func With(args ...any) *Logger {
41 return slog.With(args...)
42 }
43
44
45
46
47 func NewLogLogger(h Handler, level Level) *log.Logger {
48 return slog.NewLogLogger(h, level)
49 }
50
51
52 func Debug(msg string, args ...any) {
53 slog.Debug(msg, args...)
54 }
55
56
57 func DebugContext(ctx context.Context, msg string, args ...any) {
58 slog.DebugContext(ctx, msg, args...)
59 }
60
61
62 func Info(msg string, args ...any) {
63 slog.Info(msg, args...)
64 }
65
66
67 func InfoContext(ctx context.Context, msg string, args ...any) {
68 slog.InfoContext(ctx, msg, args...)
69 }
70
71
72 func Warn(msg string, args ...any) {
73 slog.Warn(msg, args...)
74 }
75
76
77 func WarnContext(ctx context.Context, msg string, args ...any) {
78 slog.WarnContext(ctx, msg, args...)
79 }
80
81
82 func Error(msg string, args ...any) {
83 slog.Error(msg, args...)
84 }
85
86
87 func ErrorContext(ctx context.Context, msg string, args ...any) {
88 slog.ErrorContext(ctx, msg, args...)
89 }
90
91
92 func Log(ctx context.Context, level Level, msg string, args ...any) {
93 slog.Log(ctx, level, msg, args...)
94 }
95
96
97 func LogAttrs(ctx context.Context, level Level, msg string, attrs ...Attr) {
98 slog.LogAttrs(ctx, level, msg, attrs...)
99 }
100
View as plain text