Skip to content

Commit

Permalink
upgrade logging to latest avago
Browse files Browse the repository at this point in the history
  • Loading branch information
holisticode committed Aug 12, 2022
1 parent fecd0ca commit 099e2a1
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 225 deletions.
25 changes: 13 additions & 12 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ava-labs/avalanche-network-runner/local"
"github.com/ava-labs/avalanche-network-runner/rpcpb"
"github.com/ava-labs/avalanchego/utils/logging"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
Expand Down Expand Up @@ -62,7 +63,7 @@ type client struct {
}

func New(cfg Config, log logging.Logger) (Client, error) {
log.Debug("dialing server at endpoint %s", cfg.Endpoint)
log.Debug("dialing server at ", zap.String("endpoint", cfg.Endpoint))

ctx, cancel := context.WithTimeout(context.Background(), cfg.DialTimeout)
conn, err := grpc.DialContext(
Expand Down Expand Up @@ -179,7 +180,7 @@ func (c *client) StreamStatus(ctx context.Context, pushInterval time.Duration) (
ch := make(chan *rpcpb.ClusterInfo, 1)
go func() {
defer func() {
c.log.Debug("closing stream send %s", stream.CloseSend())
c.log.Debug("closing stream send ", zap.Error(stream.CloseSend()))
close(ch)
}()
c.log.Info("start receive routine")
Expand All @@ -205,9 +206,9 @@ func (c *client) StreamStatus(ctx context.Context, pushInterval time.Duration) (
return
}
if isClientCanceled(stream.Context().Err(), err) {
c.log.Warn("failed to receive status request from gRPC stream due to client cancellation: %s", err)
c.log.Warn("failed to receive status request from gRPC stream due to client cancellation: ", zap.Error(err))
} else {
c.log.Warn("failed to receive status request from gRPC stream: %s", err)
c.log.Warn("failed to receive status request from gRPC stream:", zap.Error(err))
}
return
}
Expand All @@ -231,12 +232,12 @@ func (c *client) AddNode(ctx context.Context, name string, execPath string, opts
ChainConfigs: ret.chainConfigs,
}

c.log.Info("add node %q", name)
c.log.Info("add node", zap.String("name", name))
return c.controlc.AddNode(ctx, req)
}

func (c *client) RemoveNode(ctx context.Context, name string) (*rpcpb.RemoveNodeResponse, error) {
c.log.Info("remove node %q", name)
c.log.Info("remove node", zap.String("name", name))
return c.controlc.RemoveNode(ctx, &rpcpb.RemoveNodeRequest{Name: name})
}

Expand All @@ -252,17 +253,17 @@ func (c *client) RestartNode(ctx context.Context, name string, opts ...OpOption)
req.WhitelistedSubnets = &ret.whitelistedSubnets
}

c.log.Info("restart node %q", name)
c.log.Info("restart node", zap.String("name", name))
return c.controlc.RestartNode(ctx, req)
}

func (c *client) AttachPeer(ctx context.Context, nodeName string) (*rpcpb.AttachPeerResponse, error) {
c.log.Info("attaching peer %q", nodeName)
c.log.Info("attaching peer", zap.String("name", nodeName))
return c.controlc.AttachPeer(ctx, &rpcpb.AttachPeerRequest{NodeName: nodeName})
}

func (c *client) SendOutboundMessage(ctx context.Context, nodeName string, peerID string, op uint32, msgBody []byte) (*rpcpb.SendOutboundMessageResponse, error) {
c.log.Info("sending outbound message: node-name %s, peer-id %s", nodeName, peerID)
c.log.Info("sending outbound message", zap.String("name", nodeName), zap.String("peer-ID", peerID))
return c.controlc.SendOutboundMessage(ctx, &rpcpb.SendOutboundMessageRequest{
NodeName: nodeName,
PeerId: peerID,
Expand All @@ -272,12 +273,12 @@ func (c *client) SendOutboundMessage(ctx context.Context, nodeName string, peerI
}

func (c *client) SaveSnapshot(ctx context.Context, snapshotName string) (*rpcpb.SaveSnapshotResponse, error) {
c.log.Info("save snapshot with name %s", snapshotName)
c.log.Info("save snapshot", zap.String("snapshot-name", snapshotName))
return c.controlc.SaveSnapshot(ctx, &rpcpb.SaveSnapshotRequest{SnapshotName: snapshotName})
}

func (c *client) LoadSnapshot(ctx context.Context, snapshotName string, opts ...OpOption) (*rpcpb.LoadSnapshotResponse, error) {
c.log.Info("load snapshot with name %s", snapshotName)
c.log.Info("load snapshot", zap.String("snapshot-name", snapshotName))
ret := &Op{}
ret.applyOpts(opts)
req := rpcpb.LoadSnapshotRequest{
Expand All @@ -300,7 +301,7 @@ func (c *client) LoadSnapshot(ctx context.Context, snapshotName string, opts ...
}

func (c *client) RemoveSnapshot(ctx context.Context, snapshotName string) (*rpcpb.RemoveSnapshotResponse, error) {
c.log.Info("remove snapshot with name %s", snapshotName)
c.log.Info("remove snapshot", zap.String("snapshot-name", snapshotName))
return c.controlc.RemoveSnapshot(ctx, &rpcpb.RemoveSnapshotRequest{SnapshotName: snapshotName})
}

Expand Down
51 changes: 30 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,36 @@ module github.com/ava-labs/avalanche-network-runner

go 1.18

replace github.com/ava-labs/avalanchego => ../avalanchego-internal

replace github.com/ava-labs/avalanche-ledger-go => ../avalanche-ledger-go

require (
github.com/ava-labs/avalanchego v1.7.16
github.com/ava-labs/coreth v0.8.14-rc.0
github.com/ava-labs/coreth v0.8.15-rc.1
github.com/ethereum/go-ethereum v1.10.20
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3
github.com/onsi/ginkgo/v2 v2.1.3
github.com/onsi/ginkgo/v2 v2.1.4
github.com/onsi/gomega v1.19.0
github.com/otiai10/copy v1.7.0
github.com/prometheus/client_golang v1.12.2
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/spf13/cobra v1.3.0
github.com/stretchr/testify v1.7.2
go.uber.org/zap v1.21.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
google.golang.org/genproto v0.0.0-20220602131408-e326c6e8e9c8
google.golang.org/genproto v0.0.0-20220712132514-bdd2acd4974d
google.golang.org/grpc v1.47.0
google.golang.org/protobuf v1.28.0
)

require (
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/VictoriaMetrics/fastcache v1.10.0 // indirect
github.com/aead/siphash v1.0.1 // indirect
github.com/ava-labs/avalanche-ledger-go v0.0.0-00010101000000-000000000000 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd v0.23.1 // indirect
Expand All @@ -47,7 +53,7 @@ require (
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang-jwt/jwt v3.2.1+incompatible // indirect
github.com/golang/mock v1.6.0 // indirect
Expand All @@ -60,8 +66,8 @@ require (
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/hashicorp/go-hclog v1.0.0 // indirect
github.com/hashicorp/go-plugin v1.4.3 // indirect
github.com/hashicorp/go-hclog v1.2.2 // indirect
github.com/hashicorp/go-plugin v1.4.4 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.0.0-20200609203250-aecfd211c9ce // indirect
Expand All @@ -77,19 +83,20 @@ require (
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/kkdai/bstream v1.0.0 // indirect
github.com/linxGnu/grocksdb v1.6.34 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
Expand All @@ -99,29 +106,31 @@ require (
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/rs/cors v1.7.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.10.0 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/tyler-smith/go-bip39 v1.0.2 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
github.com/zondax/hid v0.9.0 // indirect
github.com/zondax/ledger-go v0.12.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/net v0.0.0-20220607020251-c690dde0001d // indirect
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect
golang.org/x/net v0.0.0-20220708220712-1185a9018129 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
gonum.org/v1/gonum v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/urfave/cli.v1 v1.20.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit 099e2a1

Please sign in to comment.