-
Notifications
You must be signed in to change notification settings - Fork 8
/
alias.go
62 lines (51 loc) · 1.22 KB
/
alias.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package logging
import (
"log/slog"
"time"
)
const (
LevelInfo = slog.LevelInfo
LevelWarn = slog.LevelWarn
LevelError = slog.LevelError
LevelDebug = slog.LevelDebug
)
type (
Logger = slog.Logger
Attr = slog.Attr
Level = slog.Level
Handler = slog.Handler
Value = slog.Value
HandlerOptions = slog.HandlerOptions
LogValuer = slog.LogValuer
)
var (
NewTextHandler = slog.NewTextHandler
NewJSONHandler = slog.NewJSONHandler
New = slog.New
SetDefault = slog.SetDefault
StringAttr = slog.String
BoolAttr = slog.Bool
Float64Attr = slog.Float64
AnyAttr = slog.Any
DurationAttr = slog.Duration
IntAttr = slog.Int
Int64Attr = slog.Int64
Uint64Attr = slog.Uint64
GroupValue = slog.GroupValue
Group = slog.Group
)
func Float32Attr(key string, val float32) Attr {
return slog.Float64(key, float64(val))
}
func UInt32Attr(key string, val uint32) Attr {
return slog.Int(key, int(val))
}
func Int32Attr(key string, val int32) Attr {
return slog.Int(key, int(val))
}
func TimeAttr(key string, time time.Time) Attr {
return slog.String(key, time.String())
}
func ErrAttr(err error) Attr {
return slog.String("error", err.Error())
}