MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / InitConfigAndLogger

Function InitConfigAndLogger

internal/bootstrap/config.go:32–55  ·  view source on GitHub ↗

InitConfigAndLogger initializes the configuration and sets up the logger. We allow continuing with the initialization process even if the config file loading fails. In this situation, the default config flag values are used to tweak any of the internal behaviours.

(cfg *config.Config)

Source from the content-addressed store, hash-verified

30// loading fails. In this situation, the default config flag values are used
31// to tweak any of the internal behaviours.
32func InitConfigAndLogger(cfg *config.Config) error {
33 err := cfg.TryLoadFile(cfg.File())
34 notExists := os.IsNotExist(err)
35 if err != nil && !notExists {
36 return err
37 }
38 if err := cfg.Init(); err != nil {
39 return err
40 }
41 if err == nil {
42 if err := cfg.Validate(); err != nil {
43 return err
44 }
45 }
46 if err := log.InitFromConfig(cfg.Log, "fibratus.log"); err != nil {
47 return err
48 }
49 if notExists {
50 logrus.Infof("configuration file "+
51 "%s not found. Continuing with default "+
52 "settings...", cfg.File())
53 }
54 return nil
55}

Callers 6

validateRulesFunction · 0.92
listRulesFunction · 0.92
listFilamentsFunction · 0.92
statsFunction · 0.92
printConfigFunction · 0.92
NewAppFunction · 0.85

Calls 5

InitFromConfigFunction · 0.92
TryLoadFileMethod · 0.80
FileMethod · 0.80
InitMethod · 0.45
ValidateMethod · 0.45

Tested by

no test coverage detected