cmd/chihaya: log hook names on startup
Replace logging memory addresses with actual hook names. Closes #317
This commit is contained in:
parent
1cc0738cbe
commit
86197a258c
2 changed files with 16 additions and 4 deletions
|
@ -21,6 +21,18 @@ type hookConfig struct {
|
||||||
Config interface{} `yaml:"config"`
|
Config interface{} `yaml:"config"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type hookConfigs []hookConfig
|
||||||
|
|
||||||
|
// Names returns all hook names listed in the configuration.
|
||||||
|
func (hookCfgs hookConfigs) Names() (hookNames []string) {
|
||||||
|
hookNames = make([]string, len(hookCfgs))
|
||||||
|
for index, hookCfg := range hookCfgs {
|
||||||
|
hookNames[index] = hookCfg.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Config represents the configuration used for executing Chihaya.
|
// Config represents the configuration used for executing Chihaya.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
middleware.Config `yaml:",inline"`
|
middleware.Config `yaml:",inline"`
|
||||||
|
@ -28,8 +40,8 @@ type Config struct {
|
||||||
HTTPConfig httpfrontend.Config `yaml:"http"`
|
HTTPConfig httpfrontend.Config `yaml:"http"`
|
||||||
UDPConfig udpfrontend.Config `yaml:"udp"`
|
UDPConfig udpfrontend.Config `yaml:"udp"`
|
||||||
Storage memory.Config `yaml:"storage"`
|
Storage memory.Config `yaml:"storage"`
|
||||||
PreHooks []hookConfig `yaml:"prehooks"`
|
PreHooks hookConfigs `yaml:"prehooks"`
|
||||||
PostHooks []hookConfig `yaml:"posthooks"`
|
PostHooks hookConfigs `yaml:"posthooks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateHooks creates instances of Hooks for all of the PreHooks and PostHooks
|
// CreateHooks creates instances of Hooks for all of the PreHooks and PostHooks
|
||||||
|
|
|
@ -66,8 +66,8 @@ func (r *Run) Start(ps storage.PeerStore) error {
|
||||||
return errors.New("failed to validate hook config: " + err.Error())
|
return errors.New("failed to validate hook config: " + err.Error())
|
||||||
}
|
}
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"preHooks": preHooks,
|
"preHooks": cfg.PreHooks.Names(),
|
||||||
"postHooks": postHooks,
|
"postHooks": cfg.PostHooks.Names(),
|
||||||
}).Info("starting middleware")
|
}).Info("starting middleware")
|
||||||
r.logic = middleware.NewLogic(cfg.Config, r.peerStore, preHooks, postHooks)
|
r.logic = middleware.NewLogic(cfg.Config, r.peerStore, preHooks, postHooks)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue