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:
parent
0fc62f123d
commit
a95d56741d
10
config.go
10
config.go
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user