lnd+rpcserver: initialize new log writer correctly

This commit is contained in:
Oliver Gugger 2019-09-20 16:22:02 +02:00
parent 94f49192cf
commit 3ca2c363fe
No known key found for this signature in database
GPG Key ID: 8E4256593F177720
3 changed files with 25 additions and 18 deletions

@ -951,27 +951,32 @@ func loadConfig() (*config, error) {
normalizeNetwork(activeNetParams.Name))
// Special show command to list supported subsystems and exit.
/*TODO(guggero) fix
if cfg.DebugLevel == "show" {
fmt.Println("Supported subsystems", supportedSubsystems())
fmt.Println("Supported subsystems",
logWriter.SupportedSubsystems())
os.Exit(0)
}*/
}
// Initialize logging at the default logging level.
/*TODO(guggero) fix
initLogRotator(
err = logWriter.InitLogRotator(
filepath.Join(cfg.LogDir, defaultLogFilename),
cfg.MaxLogFileSize, cfg.MaxLogFiles,
)*/
)
if err != nil {
str := "%s: log rotation setup failed: %v"
err = fmt.Errorf(str, funcName, err.Error())
fmt.Fprintln(os.Stderr, err)
return nil, err
}
// Parse, validate, and set debug log level(s).
/*TODO(guggero) fix
if err := parseAndSetDebugLevels(cfg.DebugLevel); err != nil {
err := fmt.Errorf("%s: %v", funcName, err.Error())
err = build.ParseAndSetDebugLevels(cfg.DebugLevel, logWriter)
if err != nil {
err = fmt.Errorf("%s: %v", funcName, err.Error())
fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(os.Stderr, usageMessage)
return nil, err
}*/
}
// At least one RPCListener is required. So listen on localhost per
// default.

8
lnd.go

@ -125,10 +125,10 @@ func Main(lisCfg ListenerCfg) error {
cfg = loadedConfig
defer func() {
ltndLog.Info("Shutdown complete")
/* TODO(guggero) fix after refactor
if logRotator != nil {
logRotator.Close()
}*/
err := logWriter.Close()
if err != nil {
ltndLog.Errorf("Could not close log rotator: %v", err)
}
}()
// Show version at startup.

@ -12,6 +12,7 @@ import (
"net"
"net/http"
"sort"
"strings"
"sync"
"sync/atomic"
"time"
@ -4342,7 +4343,9 @@ func (r *rpcServer) DebugLevel(ctx context.Context,
// sub-systems.
if req.Show {
return &lnrpc.DebugLevelResponse{
SubSystems: "", //TODO(guggero) fix strings.Join(supportedSubsystems(), " "),
SubSystems: strings.Join(
logWriter.SupportedSubsystems(), " ",
),
}, nil
}
@ -4350,11 +4353,10 @@ func (r *rpcServer) DebugLevel(ctx context.Context,
// Otherwise, we'll attempt to set the logging level using the
// specified level spec.
/*TODO(guggero) fix
if err := parseAndSetDebugLevels(req.LevelSpec); err != nil {
err := build.ParseAndSetDebugLevels(req.LevelSpec, logWriter)
if err != nil {
return nil, err
}
*/
return &lnrpc.DebugLevelResponse{}, nil
}