Skip to content

Commit d344984

Browse files
authored
Merge pull request #10613 from saubyk/update-getdebuginfo-rpc
Update getdebuginfo rpc
2 parents 4c5c792 + 92c0f55 commit d344984

File tree

7 files changed

+2544
-2452
lines changed

7 files changed

+2544
-2452
lines changed

cmd/commands/cmd_debug.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,26 @@ var getDebugInfoCommand = cli.Command{
2323
Category: "Debug",
2424
Usage: "Returns debug information related to the active daemon.",
2525
Action: actionDecorator(getDebugInfo),
26+
Flags: []cli.Flag{
27+
cli.BoolFlag{
28+
Name: "include_log",
29+
Usage: "if set, the log file content is " +
30+
"included in the response in " +
31+
"addition to the config",
32+
},
33+
},
2634
}
2735

36+
// getDebugInfo retrieves debug information from the daemon, optionally
37+
// including the log file content.
2838
func getDebugInfo(ctx *cli.Context) error {
2939
ctxc := getContext()
3040
client, cleanUp := getClient(ctx)
3141
defer cleanUp()
3242

33-
req := &lnrpc.GetDebugInfoRequest{}
43+
req := &lnrpc.GetDebugInfoRequest{
44+
IncludeLog: ctx.Bool("include_log"),
45+
}
3446
resp, err := client.GetDebugInfo(ctxc, req)
3547
if err != nil {
3648
return err
@@ -61,12 +73,14 @@ var encryptDebugPackageCommand = cli.Command{
6173
6274
The file by default contains the output of the following commands:
6375
- lncli getinfo
64-
- lncli getdebuginfo
76+
- lncli getdebuginfo (config only)
6577
- lncli getnetworkinfo
6678
6779
By specifying the following flags, additional information can be added
6880
to the file (usually this will be requested by the developer depending
6981
on the issue at hand):
82+
--include_log:
83+
- includes the log file content in the debug info
7084
--peers:
7185
- lncli listpeers
7286
--onchain:
@@ -113,6 +127,11 @@ var encryptDebugPackageCommand = cli.Command{
113127
"(lncli listchannels, lncli pendingchannels, " +
114128
"lncli closedchannels)",
115129
},
130+
cli.BoolFlag{
131+
Name: "include_log",
132+
Usage: "include the log file content in the " +
133+
"debug package",
134+
},
116135
},
117136
Action: actionDecorator(encryptDebugPackage),
118137
}
@@ -226,7 +245,9 @@ func collectDebugPackageInfo(ctx *cli.Context) ([]byte, error) {
226245
}
227246

228247
debugInfo, err := client.GetDebugInfo(
229-
ctxc, &lnrpc.GetDebugInfoRequest{},
248+
ctxc, &lnrpc.GetDebugInfoRequest{
249+
IncludeLog: ctx.Bool("include_log"),
250+
},
230251
)
231252
if err != nil {
232253
return nil, fmt.Errorf("error getting debug info: %w", err)

docs/release-notes/release-notes-0.21.0.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,28 @@
134134
events](https://github.com/lightningnetwork/lnd/pull/10543) to be able to
135135
subscribe to state changes.
136136

137+
* The [`GetDebugInfo`](https://github.com/lightningnetwork/lnd/pull/10613) RPC
138+
request now accepts an `include_log` flag. By default, only the configuration
139+
map is returned. When `include_log` is set to `true`, the log file content is
140+
also included in the response.
141+
137142
## lncli Updates
138143

144+
* The `getdebuginfo` command now supports an `--include_log` flag. By default,
145+
only the daemon's configuration is returned. When set, the log file content is
146+
also included in the response.
147+
148+
* The `encryptdebugpackage` command now supports an `--include_log` flag. When
149+
set, the log file content is included in the encrypted debug package.
150+
139151
## Breaking Changes
140152

153+
* The [`GetDebugInfo`](https://github.com/lightningnetwork/lnd/pull/10613) RPC
154+
no longer returns log file content by default. Clients that rely on the `log`
155+
field must now explicitly set `include_log` to `true` in the request. The
156+
`lncli getdebuginfo` and `lncli encryptdebugpackage` commands similarly
157+
require the `--include_log` flag to include logs in the output.
158+
141159
## Performance Improvements
142160

143161
* [Replace the catch-all `FilterInvoices` SQL query with five focused,

lnrpc/lightning.pb.go

Lines changed: 2455 additions & 2442 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/lightning.pb.gw.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lnrpc/lightning.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,6 +2139,9 @@ message GetInfoResponse {
21392139
}
21402140

21412141
message GetDebugInfoRequest {
2142+
// If set to true, the log file content will be included in the response.
2143+
// By default, only the config information is returned.
2144+
bool include_log = 1;
21422145
}
21432146

21442147
message GetDebugInfoResponse {

lnrpc/lightning.swagger.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,15 @@
10951095
}
10961096
}
10971097
},
1098+
"parameters": [
1099+
{
1100+
"name": "include_log",
1101+
"description": "If set to true, the log file content will be included in the response.\nBy default, only the config information is returned.",
1102+
"in": "query",
1103+
"required": false,
1104+
"type": "boolean"
1105+
}
1106+
],
10981107
"tags": [
10991108
"Lightning"
11001109
]

rpcserver.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,28 +3458,38 @@ func (r *rpcServer) GetInfo(_ context.Context,
34583458
}
34593459

34603460
// GetDebugInfo returns debug information concerning the state of the daemon
3461-
// and its subsystems. This includes the full configuration and the latest log
3462-
// entries from the log file.
3461+
// and its subsystems. By default, this returns only the configuration. If the
3462+
// `include_log` flag is set in the request, the latest log entries from the
3463+
// log file are also included.
34633464
func (r *rpcServer) GetDebugInfo(_ context.Context,
3464-
_ *lnrpc.GetDebugInfoRequest) (*lnrpc.GetDebugInfoResponse, error) {
3465+
req *lnrpc.GetDebugInfoRequest) (*lnrpc.GetDebugInfoResponse, error) {
34653466

34663467
flatConfig, _, err := configToFlatMap(*r.cfg)
34673468
if err != nil {
34683469
return nil, fmt.Errorf("error converting config to flat map: "+
34693470
"%w", err)
34703471
}
34713472

3473+
resp := &lnrpc.GetDebugInfoResponse{
3474+
Config: flatConfig,
3475+
}
3476+
3477+
// If the include_log flag is not set, we only return the config and
3478+
// skip the log file content which can be large.
3479+
if !req.IncludeLog {
3480+
return resp, nil
3481+
}
3482+
34723483
logFileName := filepath.Join(r.cfg.LogDir, defaultLogFilename)
34733484
logContent, err := os.ReadFile(logFileName)
34743485
if err != nil {
34753486
return nil, fmt.Errorf("error reading log file '%s': %w",
34763487
logFileName, err)
34773488
}
34783489

3479-
return &lnrpc.GetDebugInfoResponse{
3480-
Config: flatConfig,
3481-
Log: strings.Split(string(logContent), "\n"),
3482-
}, nil
3490+
resp.Log = strings.Split(string(logContent), "\n")
3491+
3492+
return resp, nil
34833493
}
34843494

34853495
// GetRecoveryInfo returns a boolean indicating whether the wallet is started

0 commit comments

Comments
 (0)