-
Notifications
You must be signed in to change notification settings - Fork 1
/
option.go
40 lines (34 loc) · 889 Bytes
/
option.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
package zapper
import (
"go.uber.org/zap/zapcore"
)
type Option func(*Zap)
// WithServiceDetails set service name for zapper and show service name for log files
func WithServiceDetails(serviceCode uint, serviceName string) Option {
return func(z *Zap) {
z.service = &service{serviceCode, serviceName}
}
}
// WithDebugLevel enable debug level for logging
func WithDebugLevel() Option {
return func(z *Zap) {
z.level = func(lvl zapcore.Level) bool {
return lvl <= Fatal.zapLevel()
}
}
}
// WithTimeFormat set custom time format for zapper logs
func WithTimeFormat(format TimeFormat) Option {
return func(z *Zap) {
z.timeFormat = format
}
}
// WithCustomStackTraceLevel set custom level for show stacktrace, min level warn
func WithCustomStackTraceLevel(level Level) Option {
return func(z *Zap) {
if level < Warn {
level = Error
}
z.stackLevel = level
}
}