-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption.go
43 lines (35 loc) · 933 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
41
42
43
package relogger
import (
"os"
"time"
)
// Option is to use dependency injection.
type Option interface {
apply(l *ReLogger)
}
type OptionFunc func(l *ReLogger)
func (o OptionFunc) apply(l *ReLogger) { o(l) }
// WithFileMode returns the func which sets file mode.
func WithFileMode(mode os.FileMode) OptionFunc {
return func(l *ReLogger) {
l.filemode = mode
}
}
// WithSignals returns the func which traps kill signal.
func WithSignals(signals []os.Signal) OptionFunc {
return func(l *ReLogger) {
l.signals = signals
}
}
// WithRefreshDuration returns the func which sets an interval for refreshing logger.
func WithRefreshDuration(d time.Duration) OptionFunc {
return func(l *ReLogger) {
l.refreshDuration = d
}
}
// WithPrintableDebug returns the func which sets bool to check whether debug or not.
func WithPrintableDebug(debug bool) OptionFunc {
return func(l *ReLogger) {
l.printableDebug = debug
}
}