This repository has been archived by the owner on Jun 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
boot_options.go
50 lines (39 loc) · 1.7 KB
/
boot_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
package nacelle
import (
"fmt"
"github.com/efritz/nacelle/logging"
)
type (
// LoggingInitFunc creates a factory from a config object.
LoggingInitFunc func(Config) (Logger, error)
// BootstrapperConfigFunc is a function used to configure an instance of
// a Bootstrapper.
BootstrapperConfigFunc func(*bootstrapperConfig)
)
// WithConfigSourcer sets the source that should be used for populating config structs.
func WithConfigSourcer(configSourcer ConfigSourcer) BootstrapperConfigFunc {
return func(c *bootstrapperConfig) { c.configSourcer = configSourcer }
}
// WithConfigMaskedKeys sets the keys that are redacted when printed by the config logger.
func WithConfigMaskedKeys(configMaskedKeys []string) BootstrapperConfigFunc {
return func(c *bootstrapperConfig) { c.configMaskedKeys = configMaskedKeys }
}
// WithLoggingInitFunc sets the function that initializes logging.
func WithLoggingInitFunc(loggingInitFunc LoggingInitFunc) BootstrapperConfigFunc {
return func(c *bootstrapperConfig) { c.loggingInitFunc = loggingInitFunc }
}
// WithLoggingFields sets additional fields sent with every log message.
func WithLoggingFields(loggingFields LogFields) BootstrapperConfigFunc {
return func(c *bootstrapperConfig) { c.loggingFields = loggingFields }
}
// WithRunnerOptions passes RunnerConfigFuncs to the runner created by Boot.
func WithRunnerOptions(configs ...RunnerConfigFunc) BootstrapperConfigFunc {
return func(c *bootstrapperConfig) { c.runnerConfigFuncs = configs }
}
func defaultLogginInitFunc(config Config) (Logger, error) {
c := &logging.Config{}
if err := config.Load(c); err != nil {
return nil, fmt.Errorf("could not load logging config (%s)", err.Error())
}
return logging.InitGomolShim(c)
}