forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.go
44 lines (38 loc) · 1.06 KB
/
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
package logp
// Option configures the logp package behavior.
type Option func(cfg *Config)
// WithLevel specifies the logging level.
func WithLevel(level Level) Option {
return func(cfg *Config) {
cfg.Level = level
}
}
// WithSelectors specifies what debug selectors are enabled. If no selectors are
// specified then they are all enabled.
func WithSelectors(selectors ...string) Option {
return func(cfg *Config) {
cfg.Selectors = append(cfg.Selectors, selectors...)
}
}
// ToObserverOutput specifies that the output should be collected in memory so
// that they can be read by an observer by calling ObserverLogs().
func ToObserverOutput() Option {
return func(cfg *Config) {
cfg.toObserver = true
cfg.ToStderr = false
}
}
// ToDiscardOutput configures the logger to write to io.Discard. This is for
// benchmarking purposes only.
func ToDiscardOutput() Option {
return func(cfg *Config) {
cfg.toIODiscard = true
cfg.ToStderr = false
}
}
// AsJSON specifies to log the output as JSON.
func AsJSON() Option {
return func(cfg *Config) {
cfg.JSON = true
}
}