-
Notifications
You must be signed in to change notification settings - Fork 44
/
helper.go
85 lines (68 loc) · 1.79 KB
/
helper.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package log
import (
"context"
"fmt"
)
type Helper struct {
Logger
}
// NewHelper 实例化函数
func NewHelper(log Logger) *Helper {
return &Helper{log}
}
// WithContext 调用 logger WithContext 刷新ctx
func (h *Helper) WithContext(ctx context.Context) *Helper {
return &Helper{Logger: WithContext(ctx, h.Logger)}
}
// Log .
func (h *Helper) Log(lever Lever, kvs ...interface{}) {
_ = h.Logger.Log(lever, kvs...)
}
// Debug .
func (h *Helper) Debug(a ...interface{}) {
_ = h.Logger.Log(LevelDebug, "message", fmt.Sprint(a...))
}
// Debugf .
func (h *Helper) Debugf(format string, a ...interface{}) {
h.Logger.Log(LevelDebug, "message", fmt.Sprintf(format, a...))
}
// Debugw .
func (h *Helper) Debugw(keyvals ...interface{}) {
h.Logger.Log(LevelDebug, keyvals...)
}
// Info .
func (h *Helper) Info(a ...interface{}) {
h.Logger.Log(LevelInfo, "message", fmt.Sprint(a...))
}
// Infof .
func (h *Helper) Infof(format string, a ...interface{}) {
h.Logger.Log(LevelInfo, "message", fmt.Sprintf(format, a...))
}
// Infow .
func (h *Helper) Infow(keyvals ...interface{}) {
h.Logger.Log(LevelInfo, keyvals...)
}
// Warn .
func (h *Helper) Warn(a ...interface{}) {
h.Logger.Log(LevelWarn, "message", fmt.Sprint(a...))
}
// Warnf .
func (h *Helper) Warnf(format string, a ...interface{}) {
h.Logger.Log(LevelWarn, "message", fmt.Sprintf(format, a...))
}
// Warnw .
func (h *Helper) Warnw(keyvals ...interface{}) {
h.Logger.Log(LevelWarn, keyvals...)
}
// Error .
func (h *Helper) Error(a ...interface{}) {
h.Logger.Log(LevelError, "message", fmt.Sprint(a...))
}
// Errorf .
func (h *Helper) Errorf(format string, a ...interface{}) {
h.Logger.Log(LevelError, "message", fmt.Sprintf(format, a...))
}
// Errorw .
func (h *Helper) Errorw(keyvals ...interface{}) {
h.Logger.Log(LevelError, keyvals...)
}