forked from go-admin-team/go-admin-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
63 lines (53 loc) · 902 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
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* @Author: lwnmengjing
* @Date: 2021/6/10 10:26 上午
* @Last Modified by: lwnmengjing
* @Last Modified time: 2021/6/10 10:26 上午
*/
package logger
type Option func(*options)
type options struct {
driver string
path string
level string
stdout string
cap uint
}
func setDefault() options {
return options{
driver: "default",
path: "temp/logs",
level: "warn",
stdout: "default",
}
}
func WithType(s string) Option {
return func(o *options) {
o.driver = s
}
}
func WithPath(s string) Option {
return func(o *options) {
o.path = s
}
}
func WithLevel(s string) Option {
return func(o *options) {
o.level = s
}
}
func WithStdout(s string) Option {
return func(o *options) {
o.stdout = s
}
}
func WithCap(n uint) Option {
return func(o *options) {
o.cap = n
}
}
func WithDaysToKeep(n uint) Option {
return func(o *options) {
o.cap = n
}
}