-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
50 lines (42 loc) · 891 Bytes
/
options.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
package zapmixin
import (
"github.com/fox-one/mixin-sdk-go"
"go.uber.org/zap/zapcore"
)
type Option func(*Handler) error
func WithThresholdLevel(l zapcore.Level) Option {
return func(h *Handler) error {
h.levels = getLevelThreshold(l)
return nil
}
}
func WithFixedLevel(l zapcore.Level) Option {
return func(h *Handler) error {
h.levels = []zapcore.Level{l}
return nil
}
}
func WithSync() Option {
return func(h *Handler) error {
h.async = false
return nil
}
}
func WithFormatter(f func(e zapcore.Entry) string) Option {
return func(h *Handler) error {
h.formatter = f
return nil
}
}
func WithFilter(f func(e zapcore.Entry) bool) Option {
return func(h *Handler) error {
h.filter = f
return nil
}
}
func WithAfter(f func(zapcore.Entry, *mixin.MessageRequest, error) error) Option {
return func(h *Handler) error {
h.afterFunc = f
return nil
}
}