Skip to content

Commit a51abbd

Browse files
committed
Add wallet log.
This commit adds logger for the dcrwallet.
1 parent 5088a1c commit a51abbd

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

dcrtimed/backend/filesystem/filesystem.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,6 @@ func New(root, cert, host, clientCert, clientKey string, enableCollections bool,
11471147
fs.maxDigests = maxDigests
11481148

11491149
// Runtime bits
1150-
dcrtimewallet.UseLogger(log)
11511150
fs.wallet, err = dcrtimewallet.New(cert, host, clientCert, clientKey, passphrase)
11521151
if err != nil {
11531152
return nil, err

dcrtimed/dcrtimed.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
v2 "github.com/decred/dcrtime/api/v2"
2626
"github.com/decred/dcrtime/dcrtimed/backend"
2727
"github.com/decred/dcrtime/dcrtimed/backend/filesystem"
28+
"github.com/decred/dcrtime/dcrtimed/dcrtimewallet"
2829
"github.com/decred/dcrtime/util"
2930
"github.com/gorilla/handlers"
3031
"github.com/gorilla/mux"
@@ -1442,6 +1443,9 @@ func _main() error {
14421443
log.Infof("Network : %v", activeNetParams.Params.Name)
14431444
log.Infof("Home dir: %v", loadedCfg.HomeDir)
14441445

1446+
// Sets subsystem loggers
1447+
dcrtimewallet.UseLogger(walletLog)
1448+
14451449
// Create the data directory in case it does not exist.
14461450
err = os.MkdirAll(loadedCfg.DataDir, 0700)
14471451
if err != nil {

dcrtimed/dcrtimewallet/log.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ import (
2828
var log = slog.Disabled
2929

3030
// UseLogger sets the logger to use for the gRPC server.
31-
func UseLogger(l slog.Logger) {
31+
func UseGrpcLogger(l slog.Logger) {
3232
grpclog.SetLogger(logger{l})
3333
log = l
3434
}
3535

36+
// UseLogger sets the subsystem logger for this package, without
37+
// gRPC logging.
38+
func UseLogger(l slog.Logger) {
39+
log = l
40+
}
41+
3642
// logger uses a slog.Logger to implement the grpclog.Logger interface.
3743
type logger struct {
3844
slog.Logger

dcrtimed/log.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ var (
4040
// application shutdown.
4141
logRotator *rotator.Rotator
4242

43-
log = backendLog.Logger("DCRT")
44-
fsbeLog = backendLog.Logger("FSBE")
43+
log = backendLog.Logger("DCRT")
44+
fsbeLog = backendLog.Logger("FSBE")
45+
walletLog = backendLog.Logger("DCRW")
4546
)
4647

4748
// subsystemLoggers maps each subsystem identifier to its associated logger.
4849
var subsystemLoggers = map[string]slog.Logger{
4950
"DCRT": log,
5051
"FSBE": fsbeLog,
52+
"DCRW": walletLog,
5153
}
5254

5355
// initLogRotator initializes the logging rotater to write logs to logFile and

0 commit comments

Comments
 (0)