config: don't log to stderr if lnd.conf isn't found

This commit fixes a bit of a wart in the configuration file handling
wherein if the config file isn’t found, an error was printed to stderr.
At times, this would cause the testing framework to erroneously mark as
test as failed. Instead, we now keep a particular config file error,
and check that, printing to a warning log level.
This commit is contained in:
Olaoluwa Osuntokun 2017-06-19 16:44:26 +02:00
parent 0fc62f123d
commit a95d56741d
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -159,9 +159,10 @@ func loadConfig() (*config, error) {
}
// Next, load any additional configuration options from the file.
var configFileError error
cfg := defaultCfg
if err := flags.IniParse(preCfg.ConfigFile, &cfg); err != nil {
fmt.Fprintln(os.Stderr, err)
configFileError = err
}
// Finally, parse the remaining command line options again to ensure
@ -299,6 +300,13 @@ func loadConfig() (*config, error) {
return nil, err
}
// Warn about missing config file only after all other configuration is
// done. This prevents the warning on help messages and invalid
// options. Note this should go directly before the return.
if configFileError != nil {
ltndLog.Warnf("%v", configFileError)
}
return &cfg, nil
}