Add environment override back

This commit is contained in:
Wim 2018-02-27 21:58:44 +01:00
parent 2bac867382
commit 2110db6f0c
2 changed files with 5 additions and 1 deletions

View File

@ -225,7 +225,9 @@ func OverrideCfgFromEnv(cfg *Config, protocol string, account string) {
if res != "" {
fieldVal := protoStruct.Field(i)
if fieldVal.Kind() == reflect.String {
log.Printf("config: overriding %s from env with %s\n", key, res)
log.WithFields(log.Fields{
"prefix": "config",
}).Infof("overriding %s from env with %s\n", key, res)
fieldVal.Set(reflect.ValueOf(res))
}
}

View File

@ -81,6 +81,8 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error {
br := gw.Router.getBridge(cfg.Account)
if br == nil {
br = bridge.New(cfg)
// override config from environment
config.OverrideCfgFromEnv(gw.Config, br.Protocol, br.Name)
// set logging
br.Log = log.WithFields(log.Fields{"prefix": "bridge"})
// get the protocol configuration (eg irc)