mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
Merge pull request #9278 from starius/debuglevel-show-no-checks
config: fix "lnd --debuglevel show" command
This commit is contained in:
commit
9519a23a97
21
config.go
21
config.go
@ -860,6 +860,18 @@ func LoadConfig(interceptor signal.Interceptor) (*Config, error) {
|
||||
func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
||||
flagParser *flags.Parser) (*Config, error) {
|
||||
|
||||
// Special show command to list supported subsystems and exit.
|
||||
if cfg.DebugLevel == "show" {
|
||||
subLogMgr := build.NewSubLoggerManager()
|
||||
|
||||
// Initialize logging at the default logging level.
|
||||
SetupLoggers(subLogMgr, interceptor)
|
||||
|
||||
fmt.Println("Supported subsystems",
|
||||
subLogMgr.SupportedSubsystems())
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// If the provided lnd directory is not the default, we'll modify the
|
||||
// path to all of the files and directories that will live within it.
|
||||
lndDir := CleanAndExpandPath(cfg.LndDir)
|
||||
@ -1249,7 +1261,7 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
||||
// The target network must be provided, otherwise, we won't
|
||||
// know how to initialize the daemon.
|
||||
if numNets == 0 {
|
||||
str := "either --bitcoin.mainnet, or bitcoin.testnet," +
|
||||
str := "either --bitcoin.mainnet, or bitcoin.testnet, " +
|
||||
"bitcoin.simnet, bitcoin.regtest or bitcoin.signet " +
|
||||
"must be specified"
|
||||
|
||||
@ -1408,13 +1420,6 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
||||
// Initialize logging at the default logging level.
|
||||
SetupLoggers(cfg.SubLogMgr, interceptor)
|
||||
|
||||
// Special show command to list supported subsystems and exit.
|
||||
if cfg.DebugLevel == "show" {
|
||||
fmt.Println("Supported subsystems",
|
||||
cfg.SubLogMgr.SupportedSubsystems())
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if cfg.MaxLogFiles != 0 {
|
||||
if cfg.LogConfig.File.MaxLogFiles !=
|
||||
build.DefaultMaxLogFiles {
|
||||
|
28
itest/config.go
Normal file
28
itest/config.go
Normal file
@ -0,0 +1,28 @@
|
||||
//go:build integration
|
||||
|
||||
package itest
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
|
||||
"github.com/lightningnetwork/lnd/lntest"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// testDebuglevelShow tests that "lnd --debuglevel=show" command works and
|
||||
// prints the list of supported subsystems.
|
||||
func testDebuglevelShow(ht *lntest.HarnessTest) {
|
||||
// We can't use ht.NewNode, because it adds more arguments to the
|
||||
// command line (e.g. flags configuring bitcoin backend), but we want to
|
||||
// make sure that "lnd --debuglevel=show" works without any other flags.
|
||||
lndBinary := getLndBinary(ht.T)
|
||||
cmd := exec.Command(lndBinary, "--debuglevel=show")
|
||||
stdoutStderrBytes, err := cmd.CombinedOutput()
|
||||
require.NoError(ht, err, "failed to run 'lnd --debuglevel=show'")
|
||||
|
||||
// Make sure that the output contains the list of supported subsystems
|
||||
// and that the list is not empty. We search PEER subsystem.
|
||||
stdoutStderr := string(stdoutStderrBytes)
|
||||
require.Contains(ht, stdoutStderr, "Supported subsystems")
|
||||
require.Contains(ht, stdoutStderr, "PEER")
|
||||
}
|
@ -702,4 +702,8 @@ var allTestCases = []*lntest.TestCase{
|
||||
Name: "send to route failed htlc timeout",
|
||||
TestFunc: testSendToRouteFailHTLCTimeout,
|
||||
},
|
||||
{
|
||||
Name: "debuglevel show",
|
||||
TestFunc: testDebuglevelShow,
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user