Skip to content

Commit

Permalink
addressed PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
holisticode committed Aug 10, 2022
1 parent d8afefa commit fcb0395
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 8 deletions.
5 changes: 4 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ func New(cfg Config) (Client, error) {
}
lcfg := logging.Config{
DisplayLevel: lvl,
LogLevel: lvl,
// this will result in no written logs, just stdout
// to enable log files, a logDir param should be added and
// accordingly possibly a flag
LogLevel: logging.Off,
}
logFactory := logging.NewFactory(lcfg)
log, err := logFactory.Make(constants.LogNameClient)
Expand Down
5 changes: 4 additions & 1 deletion cmd/control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ func NewCommand() *cobra.Command {

lcfg := logging.Config{
DisplayLevel: logging.Info,
LogLevel: logging.Debug,
// this will result in no written logs, just stdout
// to enable log files, a logDir param should be added and
// accordingly possibly a flag
LogLevel: logging.Off,
}
logFactory := logging.NewFactory(lcfg)
var err error
Expand Down
3 changes: 2 additions & 1 deletion cmd/ping/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/ava-labs/avalanche-network-runner/client"
"github.com/ava-labs/avalanche-network-runner/utils/constants"
"github.com/ava-labs/avalanche-network-runner/ux"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -41,7 +42,7 @@ func pingFunc(cmd *cobra.Command, args []string) error {
}
logFactory := logging.NewFactory(lcfg)
var err error
log, err := logFactory.Make("control")
log, err := logFactory.Make(constants.LogNameControl)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewCommand() *cobra.Command {
Args: cobra.ExactArgs(0),
}

cmd.PersistentFlags().StringVar(&logLevel, "log-level", logging.Info.String(), "log level")
cmd.PersistentFlags().StringVar(&logLevel, "log-level", logging.Info.String(), "log level for server logs")
cmd.PersistentFlags().StringVar(&logDir, "log-dir", "", "log directory")
cmd.PersistentFlags().StringVar(&port, "port", ":8080", "server port")
cmd.PersistentFlags().StringVar(&gwPort, "grpc-gateway-port", ":8081", "grpc-gateway server port")
Expand Down Expand Up @@ -101,11 +101,11 @@ func serverFunc(cmd *cobra.Command, args []string) (err error) {
rootCancel()
// wait for server stop
waitForServerStop := <-errc
log.Warn("closed server; %w", waitForServerStop)
log.Warn("closed server; %s", waitForServerStop)
case serverClosed := <-errc:
// server already stopped here
_ = rootCancel
log.Warn("server closed: %w", serverClosed)
log.Warn("server closed: %s", serverClosed)
}
return err
}
2 changes: 1 addition & 1 deletion local/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (ln *localNetwork) waitForCustomChainsReady(
break
}

ln.log.Info("log not found yet, retrying... vm-id: %s, subnet-id: %s, blockchain-id: %s, log-path: %s, err: %w",
ln.log.Info("log not found yet, retrying... vm-id: %s, subnet-id: %s, blockchain-id: %s, log-path: %s, err: %s",
chainInfo.vmID.String(),
chainInfo.subnetID.String(),
chainInfo.blockchainID.String(),
Expand Down
2 changes: 1 addition & 1 deletion server/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,6 @@ func (lc *localNetwork) stop(ctx context.Context) {
}
serr := lc.nw.Stop(ctx)
<-lc.startDoneCh
ux.Print(lc.log, logging.Red.Wrap(logging.Bold.Wrap("terminated network (error %w)")), serr)
ux.Print(lc.log, logging.Red.Wrap(logging.Bold.Wrap("terminated network (error %s)")), serr)
})
}
13 changes: 13 additions & 0 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package e2e_test
import (
"context"
"flag"
"fmt"
"io/fs"
"os"
"path/filepath"
Expand Down Expand Up @@ -40,6 +41,7 @@ func TestE2e(t *testing.T) {

var (
logLevel string
logDir string
gRPCEp string
gRPCGatewayEp string
execPath1 string
Expand All @@ -66,6 +68,12 @@ func init() {
logging.Info.String(),
"log level",
)
flag.StringVar(
&logDir,
"log-dir",
logging.Info.String(),
"log directory",
)
flag.StringVar(
&gRPCEp,
"grpc-endpoint",
Expand Down Expand Up @@ -104,6 +112,11 @@ var (
)

var _ = ginkgo.BeforeSuite(func() {
if logDir == "" {
var err error
logDir, err = os.MkdirTemp("", fmt.Sprintf("anr-e2e-logs-%d", time.Now().Unix()))
gomega.Ω(err).Should(gomega.BeNil())
}
lvl, err := logging.ToLevel(logLevel)
gomega.Ω(err).Should(gomega.BeNil())
lcfg := logging.Config{
Expand Down

0 comments on commit fcb0395

Please sign in to comment.