config: register subserver loggers before validation

Ensure that all of Lit's subserver loggers have been registered _before_
the config is validated. This will allow users to use the
`--lnd.debuglevel` flag to set Lit specific subserever logger levels.
This commit is contained in:
Elle Mouton 2023-05-02 12:21:46 +02:00
parent 06bb73f62d
commit daab70c040
No known key found for this signature in database
GPG key ID: D7D916376026F177

View file

@ -328,6 +328,12 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
os.Exit(0)
}
// Before we validate the config, we first hook up our own loggers.
// This must be done before the config is validated if LND is running
// in integrated mode so that the log levels for various non-LND related
// subsystems can be set via the `lnd.debuglevel` flag.
SetupLoggers(preCfg.Lnd.LogWriter, interceptor)
// Load the main configuration file and parse any command line options.
// This function will also set up logging properly.
cfg, err := loadConfigFile(preCfg, interceptor)
@ -335,10 +341,6 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
return nil, err
}
// With the validated config obtained, we now know that the root logging
// system of lnd is initialized and we can hook up our own loggers now.
SetupLoggers(cfg.Lnd.LogWriter, interceptor)
// Translate the more user friendly string modes into the more developer
// friendly internal bool variables now.
cfg.lndRemote = cfg.LndMode == ModeRemote