Skip to content

Commit

Permalink
this was already implemented for config
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Dec 16, 2024
1 parent f1e84cf commit 31e4b1e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
33 changes: 0 additions & 33 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ package main

import (
"os"
"strings"

"decred.org/dcrwallet/v5/chain"
"decred.org/dcrwallet/v5/errors"
"decred.org/dcrwallet/v5/internal/loader"
"decred.org/dcrwallet/v5/internal/loggers"
"decred.org/dcrwallet/v5/internal/rpc/jsonrpc"
Expand Down Expand Up @@ -85,37 +83,6 @@ func setLogLevels(logLevel string) {
}
}

// setLogLevelSpec sets all loggers, or a specific logger (when levelSpec is
// prefixed by the subsystem and an equals sign) to a particular log level.
func setLogLevelSpec(levelSpec string) error {
var subsys, level string

equals := strings.Index(levelSpec, "=")
if equals != -1 {
subsys = levelSpec[:equals]
level = levelSpec[equals+1:]
} else {
level = levelSpec
}

if subsys != "" {
if _, ok := subsystemLoggers[subsys]; !ok {
return errors.Errorf("subsystem %q does not exist", subsys)
}
}

if _, ok := slog.LevelFromString(level); !ok {
return errors.Errorf("%q is not a valid log level", level)
}

if subsys != "" {
setLogLevel(subsys, level)
} else {
setLogLevels(level)
}
return nil
}

// fatalf logs a message, flushes the logger, and finally exit the process with
// a non-zero return code.
func fatalf(format string, args ...any) {
Expand Down
2 changes: 1 addition & 1 deletion rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (rpcLoggers) Subsystems() []string {
}

func (rpcLoggers) SetLevels(levelSpec string) error {
return setLogLevelSpec(levelSpec)
return parseAndSetDebugLevels(levelSpec)
}

func startRPCServers(walletLoader *loader.Loader) (*grpc.Server, *jsonrpc.Server, error) {
Expand Down

0 comments on commit 31e4b1e

Please sign in to comment.