rpc: return loglevels of the current subsystems

This commit is contained in:
ziggie 2024-09-24 23:41:07 +02:00
parent f46ae2f893
commit 8d4d3e0323
No known key found for this signature in database
GPG Key ID: 1AFF9C4DCED6D666

View File

@ -7355,10 +7355,28 @@ func (r *rpcServer) DebugLevel(ctx context.Context,
return nil, err return nil, err
} }
// Propagate the new config level to the main config struct. subLoggers := r.cfg.LogWriter.SubLoggers()
r.cfg.DebugLevel = req.LevelSpec // 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 // DecodePayReq takes an encoded payment request string and attempts to decode