From 8d4d3e0323f0eb2159227b3a815117f10a712567 Mon Sep 17 00:00:00 2001 From: ziggie Date: Tue, 24 Sep 2024 23:41:07 +0200 Subject: [PATCH] rpc: return loglevels of the current subsystems --- rpcserver.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 774e6d9c6..6f43adf7f 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -7355,10 +7355,28 @@ func (r *rpcServer) DebugLevel(ctx context.Context, return nil, err } - // Propagate the new config level to the main config struct. - r.cfg.DebugLevel = req.LevelSpec + subLoggers := r.cfg.LogWriter.SubLoggers() + // Sort alphabetically by subsystem name. + var tags []string + for t := range subLoggers { + tags = append(tags, t) + } + sort.Strings(tags) - return &lnrpc.DebugLevelResponse{}, nil + // Create the log levels string. + var logLevels []string + for _, t := range tags { + logLevels = append(logLevels, fmt.Sprintf("%s=%s", t, + subLoggers[t].Level().String())) + } + logLevelsString := strings.Join(logLevels, ", ") + + // Propagate the new config level to the main config struct. + r.cfg.DebugLevel = logLevelsString + + return &lnrpc.DebugLevelResponse{ + SubSystems: logLevelsString, + }, nil } // DecodePayReq takes an encoded payment request string and attempts to decode