From 6fcb627af876c5e82ff5bf1cfb7a31e792841fab Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Thu, 10 Jan 2019 23:23:24 -0800 Subject: [PATCH] Use our own stdout log handler This logic used to live in our copy of log, but is not in vendored Ethereum version. --- cmd/beaconchain/main.go | 2 +- cmd/client/txgen/main.go | 2 +- cmd/client/wallet/main.go | 6 +++++- cmd/harmony.go | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/beaconchain/main.go b/cmd/beaconchain/main.go index 62ab56332..98e451683 100644 --- a/cmd/beaconchain/main.go +++ b/cmd/beaconchain/main.go @@ -34,7 +34,7 @@ func main() { printVersion(os.Args[0]) } - h := log.StdoutHandler + h := log.StreamHandler(os.Stdout, log.TerminalFormat(false)) log.Root().SetHandler(h) bc := beaconchain.New(*numShards, *ip, *port) diff --git a/cmd/client/txgen/main.go b/cmd/client/txgen/main.go index ce4fb5b08..e4710e789 100644 --- a/cmd/client/txgen/main.go +++ b/cmd/client/txgen/main.go @@ -88,7 +88,7 @@ func main() { // Setup a logger to stdout and log file. logFileName := fmt.Sprintf("./%v/txgen.log", *logFolder) h := log.MultiHandler( - log.StdoutHandler, + log.StreamHandler(os.Stdout, log.TerminalFormat(false)), log.Must.FileHandler(logFileName, log.LogfmtFormat()), // Log to file ) log.Root().SetHandler(h) diff --git a/cmd/client/wallet/main.go b/cmd/client/wallet/main.go index 6cfac58b1..8283525bc 100644 --- a/cmd/client/wallet/main.go +++ b/cmd/client/wallet/main.go @@ -16,13 +16,14 @@ import ( "github.com/ethereum/go-ethereum/common" crypto2 "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/harmony-one/harmony/api/client" clientService "github.com/harmony-one/harmony/api/client/service" proto_node "github.com/harmony-one/harmony/api/proto/node" "github.com/harmony-one/harmony/core/types" libs "github.com/harmony-one/harmony/internal/beaconchain/libs" - "github.com/harmony-one/harmony/internal/beaconchain/rpc" + beaconchain "github.com/harmony-one/harmony/internal/beaconchain/rpc" "github.com/harmony-one/harmony/node" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/p2pimpl" @@ -49,6 +50,9 @@ type AccountState struct { // The main wallet program entrance. Note the this wallet program is for demo-purpose only. It does not implement // the secure storage of keys. func main() { + h := log.StreamHandler(os.Stdout, log.TerminalFormat(false)) + log.Root().SetHandler(h) + // Account subcommands accountImportCommand := flag.NewFlagSet("import", flag.ExitOnError) accountImportPtr := accountImportCommand.String("privateKey", "", "Specify the private key to import") diff --git a/cmd/harmony.go b/cmd/harmony.go index 5a89214c0..4123309e2 100644 --- a/cmd/harmony.go +++ b/cmd/harmony.go @@ -64,7 +64,7 @@ func loggingInit(logFolder, role, ip, port string, onlyLogTps bool) { // Setup a logger to stdout and log file. logFileName := fmt.Sprintf("./%v/%s-%v-%v.log", logFolder, role, ip, port) h := log.MultiHandler( - log.StdoutHandler, + log.StreamHandler(os.Stdout, log.TerminalFormat(false)), log.Must.FileHandler(logFileName, log.JSONFormat()), // Log to file ) if onlyLogTps {