Skip to content

Commit

Permalink
multi: move ParseAndSetDebugLevels out of ValidateConfig
Browse files Browse the repository at this point in the history
We need to move the call that sets all log levels out of the config
validation. Otherwise this will overwrite all subsystem log levels in
LiT where we call the faraday.ValidateConfig() function but have already
set up our loggers.

At the same time we remove the unnecessary global logWriter variable.
  • Loading branch information
guggero committed May 31, 2021
1 parent 4f63e3e commit a51f229
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
5 changes: 0 additions & 5 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/btcsuite/btcutil"
"github.com/lightninglabs/lndclient"
"github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/cert"
"github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc"
Expand Down Expand Up @@ -290,10 +289,6 @@ func ValidateConfig(config *Config) error {
)
}

if err := build.ParseAndSetDebugLevels(config.DebugLevel, logWriter); err != nil {
return err
}

return nil
}

Expand Down
6 changes: 6 additions & 0 deletions faraday.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ func Main() error {
if err != nil {
return err
}

// Setup logging before parsing the config.
logWriter := build.NewRotatingLogWriter()
SetupLoggers(logWriter, shutdownInterceptor)
err = build.ParseAndSetDebugLevels(config.DebugLevel, logWriter)
if err != nil {
return err
}

if err := ValidateConfig(&config); err != nil {
return fmt.Errorf("error validating config: %v", err)
Expand Down
3 changes: 0 additions & 3 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
const Subsystem = "FRDY"

var (
logWriter *build.RotatingLogWriter

// log is a logger that is initialized with no output filters. This
// means the package will not perform any logging by default until the
// caller requests it.
Expand All @@ -29,7 +27,6 @@ var (
func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor) {
genLogger := genSubLogger(root, intercept)

logWriter = root
log = build.NewSubLogger(Subsystem, genLogger)

setSubLogger(root, Subsystem, log, nil)
Expand Down

0 comments on commit a51f229

Please sign in to comment.