-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
48 lines (37 loc) · 882 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
package initializer
import (
"fmt"
"github.com/rakunlabs/into"
"github.com/worldline-go/logz"
)
type option struct {
msg string
logzOptions []logz.Option
intoOptions []into.Option
}
type Option func(options *option)
// WithMsg is a function that sets the message to be logged when the application starts.
//
// This will override the default message.
func WithMsgf(format string, a ...any) Option {
return func(options *option) {
options.msg = fmt.Sprintf(format, a...)
}
}
func WithOptionsLogz(logzOpts ...logz.Option) Option {
return func(options *option) {
options.logzOptions = logzOpts
}
}
func WithOptionsInto(intoOpts ...into.Option) Option {
return func(options *option) {
options.intoOptions = intoOpts
}
}
func optionInitRunner(options ...Option) *option {
option := &option{}
for _, opt := range options {
opt(option)
}
return option
}