@@ -336,6 +336,23 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
336
336
cfg .loopRemote = cfg .LoopMode == ModeRemote
337
337
cfg .poolRemote = cfg .PoolMode == ModeRemote
338
338
339
+ // Now that we've registered all loggers, let's parse, validate, and set
340
+ // the debug log level(s). In remote lnd mode we have a global log level
341
+ // that overwrites all others. In integrated mode we use the lnd log
342
+ // level as the master level.
343
+ if cfg .lndRemote {
344
+ err = build .ParseAndSetDebugLevels (
345
+ cfg .Remote .LitDebugLevel , cfg .Lnd .LogWriter ,
346
+ )
347
+ } else {
348
+ err = build .ParseAndSetDebugLevels (
349
+ cfg .Lnd .DebugLevel , cfg .Lnd .LogWriter ,
350
+ )
351
+ }
352
+ if err != nil {
353
+ return nil , err
354
+ }
355
+
339
356
// Validate the lightning-terminal config options.
340
357
litDir := lnd .CleanAndExpandPath (preCfg .LitDir )
341
358
cfg .LetsEncryptDir = lncfg .CleanAndExpandPath (cfg .LetsEncryptDir )
@@ -378,14 +395,18 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
378
395
// (like the log or lnd options) as they will be taken from lnd's config
379
396
// struct. Others we want to force to be the same as lnd so the user
380
397
// doesn't have to set them manually, like the network for example.
398
+ cfg .Faraday .Lnd .MacaroonPath = faraday .DefaultLndMacaroonPath
381
399
if err := faraday .ValidateConfig (cfg .Faraday ); err != nil {
382
400
return nil , err
383
401
}
384
- cfg .Loop .Lnd .MacaroonPath = loopd .DefaultMacaroonPath
402
+
403
+ defaultLoopCfg := loopd .DefaultConfig ()
404
+ cfg .Loop .Lnd .MacaroonPath = defaultLoopCfg .Lnd .MacaroonPath
385
405
if err := loopd .Validate (cfg .Loop ); err != nil {
386
406
return nil , err
387
407
}
388
- cfg .Pool .Lnd .MacaroonPath = pool .DefaultMacaroonPath
408
+
409
+ cfg .Pool .Lnd .MacaroonPath = pool .DefaultLndMacaroonPath
389
410
if err := pool .Validate (cfg .Pool ); err != nil {
390
411
return nil , err
391
412
}
@@ -419,7 +440,6 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
419
440
}
420
441
}
421
442
422
- defaultLoopCfg := loopd .DefaultConfig ()
423
443
if cfg .loopRemote && cfg .Network != defaultNetwork {
424
444
if cfg .Remote .Loop .MacaroonPath == defaultLoopCfg .MacaroonPath {
425
445
cfg .Remote .Loop .MacaroonPath = cfg .Loop .MacaroonPath
@@ -576,21 +596,21 @@ func validateRemoteModeConfig(cfg *Config) error {
576
596
}
577
597
578
598
// In remote mode, we don't call lnd's ValidateConfig that sets up a
579
- // logging backend for us. We need to manually create and start one.
580
- logWriter := build .NewRotatingLogWriter ()
581
- cfg .Lnd .LogWriter = logWriter
582
- err := logWriter .InitLogRotator (
599
+ // logging backend for us. We need to manually create and start one. The
600
+ // root logger should've already been created as part of the default
601
+ // config though.
602
+ if cfg .Lnd .LogWriter == nil {
603
+ cfg .Lnd .LogWriter = build .NewRotatingLogWriter ()
604
+ }
605
+ err := cfg .Lnd .LogWriter .InitLogRotator (
583
606
filepath .Join (r .LitLogDir , cfg .Network , defaultLogFilename ),
584
607
r .LitMaxLogFileSize , r .LitMaxLogFiles ,
585
608
)
586
609
if err != nil {
587
610
return fmt .Errorf ("log rotation setup failed: %v" , err .Error ())
588
611
}
589
612
590
- // Parse, validate, and set debug log level(s).
591
- return build .ParseAndSetDebugLevels (
592
- cfg .Remote .LitDebugLevel , logWriter ,
593
- )
613
+ return nil
594
614
}
595
615
596
616
// setNetwork parses the top-level network config options and, if valid, sets it
0 commit comments