Skip to content

Commit

Permalink
rpc: use existing rpc logger for wtclientrpc
Browse files Browse the repository at this point in the history
The logger string used to identify the wtclient and wtclientrpc loggers
was the same, leading to being unable to modify the log level of the
wtclient logger as it would be overwritten with the wtclientrpc's one.
To simplify things, we decide to use the existing RPC logger for
wtclientrpc.
  • Loading branch information
wpaulino committed May 14, 2020
1 parent ec5c941 commit b195d39
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 53 deletions.
4 changes: 4 additions & 0 deletions lnrpc/wtclientrpc/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wtclientrpc

import (
"github.com/btcsuite/btclog"
"github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/watchtower/wtclient"
)
Expand All @@ -22,4 +23,7 @@ type Config struct {
// addresses to ensure we don't leak any information when running over
// non-clear networks, e.g. Tor, etc.
Resolver lncfg.TCPResolver

// Log is the logger instance we should log output to.
Log btclog.Logger
}
48 changes: 0 additions & 48 deletions lnrpc/wtclientrpc/log.go

This file was deleted.

4 changes: 2 additions & 2 deletions lnrpc/wtclientrpc/wtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ func (c *WatchtowerClient) RegisterWithRootServer(grpcServer *grpc.Server) error
// all our methods are routed properly.
RegisterWatchtowerClientServer(grpcServer, c)

log.Debugf("WatchtowerClient RPC server successfully registered with " +
"root gRPC server")
c.cfg.Log.Debugf("WatchtowerClient RPC server successfully registered " +
"with root gRPC server")

return nil
}
Expand Down
2 changes: 0 additions & 2 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
"github.com/lightningnetwork/lnd/lnrpc/verrpc"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
"github.com/lightningnetwork/lnd/lnrpc/wtclientrpc"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
"github.com/lightningnetwork/lnd/monitoring"
Expand Down Expand Up @@ -102,7 +101,6 @@ func init() {

addSubLogger(routing.Subsystem, routing.UseLogger, localchans.UseLogger)
addSubLogger(routerrpc.Subsystem, routerrpc.UseLogger)
addSubLogger(wtclientrpc.Subsystem, wtclientrpc.UseLogger)
addSubLogger(chanfitness.Subsystem, chanfitness.UseLogger)
addSubLogger(verrpc.Subsystem, verrpc.UseLogger)
}
Expand Down
1 change: 1 addition & 0 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ func newRPCServer(s *server, macService *macaroons.Service,
s.htlcSwitch, activeNetParams.Params, s.chanRouter,
routerBackend, s.nodeSigner, s.chanDB, s.sweeper, tower,
s.towerClient, cfg.net.ResolveTCPAddr, genInvoiceFeatures,
rpcsLog,
)
if err != nil {
return nil, err
Expand Down
7 changes: 6 additions & 1 deletion subrpcserver_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"reflect"

"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btclog"
"github.com/lightningnetwork/lnd/autopilot"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/htlcswitch"
Expand Down Expand Up @@ -94,7 +95,8 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
tower *watchtower.Standalone,
towerClient wtclient.Client,
tcpResolver lncfg.TCPResolver,
genInvoiceFeatures func() *lnwire.FeatureVector) error {
genInvoiceFeatures func() *lnwire.FeatureVector,
rpcLogger btclog.Logger) error {

// First, we'll use reflect to obtain a version of the config struct
// that allows us to programmatically inspect its fields.
Expand Down Expand Up @@ -244,6 +246,9 @@ func (s *subRPCServerConfigs) PopulateDependencies(cc *chainControl,
subCfgValue.FieldByName("Resolver").Set(
reflect.ValueOf(tcpResolver),
)
subCfgValue.FieldByName("Log").Set(
reflect.ValueOf(rpcLogger),
)

default:
return fmt.Errorf("unknown field: %v, %T", fieldName,
Expand Down

0 comments on commit b195d39

Please sign in to comment.