From e61cbcbce0d8bbb02c306ba1cf5f9a5cfe05ea39 Mon Sep 17 00:00:00 2001 From: jongwhan lee Date: Sat, 17 Jul 2021 16:37:08 +0900 Subject: [PATCH] Problem: verbose logs display with FATAL option (fix #320) add my script increase amount for metamask add run amount ok hide log show info my logger hook log revive eth log tidy up use suplog log replace ok removed suplog tidy up tidy up fix compile remove sh tidy up tidy up --- app/ante/ante.go | 9 +++++---- cmd/ethermintd/root.go | 1 + go.mod | 8 +------- go.sum | 22 ---------------------- log/log.go | 25 +++++++++++++++++++++++++ server/start.go | 14 ++++++++++++-- server/util.go | 13 +++++++------ x/evm/handler.go | 10 ++++++---- x/evm/types/utils.go | 5 ++--- 9 files changed, 59 insertions(+), 48 deletions(-) create mode 100644 log/log.go diff --git a/app/ante/ante.go b/app/ante/ante.go index 45a6ed79c1..e12b64ed13 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -1,10 +1,10 @@ package ante import ( + "fmt" "runtime/debug" "github.com/palantir/stacktrace" - log "github.com/xlab/suplog" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -14,6 +14,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/tharsis/ethermint/crypto/ethsecp256k1" + mintlog "github.com/tharsis/ethermint/log" ) const ( @@ -120,10 +121,10 @@ func Recover(err *error) { *err = sdkerrors.Wrapf(sdkerrors.ErrPanic, "%v", r) if e, ok := r.(error); ok { - log.WithError(e).Errorln("ante handler panicked with an error") - log.Debugln(string(debug.Stack())) + (*mintlog.EthermintLoggerInstance.TendermintLogger).Error(fmt.Sprintf("ante handler panicked with an error %v", e)) + (*mintlog.EthermintLoggerInstance.TendermintLogger).Debug(string(debug.Stack())) } else { - log.Errorln(r) + (*mintlog.EthermintLoggerInstance.TendermintLogger).Error(fmt.Sprintf("%v", r)) } } } diff --git a/cmd/ethermintd/root.go b/cmd/ethermintd/root.go index 9e07460958..7e70f9052f 100644 --- a/cmd/ethermintd/root.go +++ b/cmd/ethermintd/root.go @@ -178,6 +178,7 @@ type appCreator struct { // newApp is an appCreator func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { + var cache sdk.MultiStorePersistentCache if cast.ToBool(appOpts.Get(sdkserver.FlagInterBlockCache)) { diff --git a/go.mod b/go.mod index e9d317e9f6..d02db61cc4 100644 --- a/go.mod +++ b/go.mod @@ -4,19 +4,14 @@ go 1.15 require ( github.com/armon/go-metrics v0.3.9 - github.com/aws/aws-sdk-go v1.38.21 // indirect - github.com/bitly/go-simplejson v0.5.0 // indirect github.com/btcsuite/btcd v0.22.0-beta github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce - github.com/bugsnag/bugsnag-go v2.1.0+incompatible // indirect - github.com/bugsnag/panicwrap v1.3.2 // indirect github.com/cespare/cp v1.1.1 // indirect github.com/cosmos/cosmos-sdk v0.43.0-rc1 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/ibc-go v1.0.0-beta1 github.com/deckarep/golang-set v1.7.1 // indirect github.com/ethereum/go-ethereum v1.10.3 - github.com/gofrs/uuid v4.0.0+incompatible // indirect github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 github.com/google/uuid v1.2.0 // indirect @@ -25,7 +20,6 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-immutable-radix v1.3.0 // indirect github.com/improbable-eng/grpc-web v0.14.0 - github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect github.com/miguelmota/go-ethereum-hdwallet v0.0.1 github.com/palantir/stacktrace v0.0.0-20161112013806-78658fd2d177 github.com/pkg/errors v0.9.1 @@ -34,6 +28,7 @@ require ( github.com/regen-network/cosmos-proto v0.3.1 github.com/rjeczalik/notify v0.9.2 // indirect github.com/rs/cors v1.7.0 + github.com/sirupsen/logrus v1.8.1 github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.1.3 github.com/spf13/viper v1.8.1 @@ -43,7 +38,6 @@ require ( github.com/tendermint/tm-db v0.6.4 github.com/tyler-smith/go-bip39 v1.1.0 github.com/xlab/closer v0.0.0-20190328110542-03326addb7c2 - github.com/xlab/suplog v1.3.0 golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect google.golang.org/genproto v0.0.0-20210712171009-5404628d0f46 google.golang.org/grpc v1.39.0 diff --git a/go.sum b/go.sum index 543e0eb049..44d3397b70 100644 --- a/go.sum +++ b/go.sum @@ -112,11 +112,8 @@ github.com/armon/go-metrics v0.3.9/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4 github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= -github.com/aws/aws-sdk-go v1.25.16/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.38.21 h1:D08DXWI4QRaawLaW+OtsIEClOI90I6eheJs1GwXTQVI= -github.com/aws/aws-sdk-go v1.38.21/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.2.0/go.mod h1:zEQs02YRBw1DjK0PoJv3ygDYOFTre1ejlJWl8FwAuQo= github.com/aws/aws-sdk-go-v2/config v1.1.1/go.mod h1:0XsVy9lBI/BCXm+2Tuvt39YmdHwS5unDQmxZOYe8F5Y= @@ -133,12 +130,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y= -github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= -github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= -github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= @@ -162,9 +155,6 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/bugsnag/bugsnag-go v1.5.3/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= -github.com/bugsnag/bugsnag-go v2.1.0+incompatible h1:SuqsBHDutts2rZh4swHEWTexxi0F/JZ/6j1rR9BFe7I= -github.com/bugsnag/bugsnag-go v2.1.0+incompatible/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -357,8 +347,6 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= @@ -567,9 +555,7 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS github.com/jhump/protoreflect v1.8.2 h1:k2xE7wcUomeqwY0LDCYA16y4WWfyTcMx5mKhk0d4ua0= github.com/jhump/protoreflect v1.8.2/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= @@ -595,8 +581,6 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356 h1:I/yrLt2WilKxlQKCM52clh5rGzTKpVctGT1lH4Dc8Jw= github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= -github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= -github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= github.com/kilic/bls12-381 v0.0.0-20201226121925-69dacb279461/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig= @@ -715,7 +699,6 @@ github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= @@ -1005,15 +988,11 @@ github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0 github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/closer v0.0.0-20190328110542-03326addb7c2 h1:LPYwXwwHigHHFX3SFa9W9zBIa5reyaLJos2e95eHh68= github.com/xlab/closer v0.0.0-20190328110542-03326addb7c2/go.mod h1:Y8IYP9aVODN3Vnw1FCqygCG5IWyYBeBlZqQ5aX+fHFw= -github.com/xlab/suplog v1.3.0 h1:bbnKR8R8gSs2Q4Y25u2xH6shNNV/4r+bNspqViJQTLY= -github.com/xlab/suplog v1.3.0/go.mod h1:Fq+wOrO0v1DZhfHxgCFB/MlFMzost3Mf/xLuJlfyUA0= github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xtaci/kcp-go v5.4.20+incompatible/go.mod h1:bN6vIwHQbfHaHtFpEssmWsN45a+AZwO7eyRCmEIbtvE= github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE= github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE= -github.com/yihuang/panicwrap v1.3.4-0.20210716032932-61c0a7c0cd05 h1:pAujDEt8f+lZIOOfVXpkoMemkOi0e6On1aaZWK4dxSM= -github.com/yihuang/panicwrap v1.3.4-0.20210716032932-61c0a7c0cd05/go.mod h1:AeUysGSIOPvhV1BZNplN56n5EEm3YfgYc/X3mhpjRiA= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1166,7 +1145,6 @@ golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= diff --git a/log/log.go b/log/log.go new file mode 100644 index 0000000000..c68e8f026b --- /dev/null +++ b/log/log.go @@ -0,0 +1,25 @@ +package log + +import ( + tmlog "github.com/tendermint/tendermint/libs/log" + + "github.com/sirupsen/logrus" +) + +type EthermintLogger struct { + TendermintLogger *tmlog.Logger +} + +func (f EthermintLogger) Levels() []logrus.Level { + //return make([]logrus.Level, 0) + return []logrus.Level{logrus.DebugLevel, logrus.InfoLevel, logrus.TraceLevel, logrus.WarnLevel} +} + +func (f EthermintLogger) Fire(entry *logrus.Entry) error { + // a, _ := (*entry).String() + a := (*entry).Message + (*f.TendermintLogger).Info(a) + return nil +} + +var EthermintLoggerInstance EthermintLogger = EthermintLogger{nil} diff --git a/server/start.go b/server/start.go index 4c6c6afa35..1ca88e4c65 100644 --- a/server/start.go +++ b/server/start.go @@ -2,6 +2,7 @@ package server import ( "context" + "fmt" "io" "net" "net/http" @@ -15,6 +16,7 @@ import ( "github.com/rs/cors" "github.com/spf13/cobra" "github.com/xlab/closer" + "google.golang.org/grpc" tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" @@ -35,12 +37,13 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - ethlog "github.com/ethereum/go-ethereum/log" ethrpc "github.com/ethereum/go-ethereum/rpc" + ethlog "github.com/ethereum/go-ethereum/log" "github.com/tharsis/ethermint/cmd/ethermintd/config" "github.com/tharsis/ethermint/ethereum/rpc" ethdebug "github.com/tharsis/ethermint/ethereum/rpc/namespaces/debug" + mintlog "github.com/tharsis/ethermint/log" ) // Tendermint full-node start flags @@ -170,6 +173,10 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty home := cfg.RootDir logger := ctx.Logger + mintlog.EthermintLoggerInstance.TendermintLogger = &logger + + (*mintlog.EthermintLoggerInstance.TendermintLogger).Info(fmt.Sprintf("startInProcess ~~~~~~~~ %s", ctx.Config.LogLevel)) + traceWriterFile := ctx.Viper.GetString(flagTraceStore) db, err := openDB(home) if err != nil { @@ -238,7 +245,10 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty var httpSrvDone = make(chan struct{}, 1) var wsSrv rpc.WebsocketsServer - ethlog.Root().SetHandler(ethlog.StdoutHandler) + if ctx.Config.LogLevel == "debug" { + ethlog.Root().SetHandler(ethlog.StdoutHandler) + } + if config.EVMRPC.Enable { tmEndpoint := "/websocket" tmRPCAddr := cfg.RPC.ListenAddress diff --git a/server/util.go b/server/util.go index 219b670353..ee110f4718 100644 --- a/server/util.go +++ b/server/util.go @@ -1,13 +1,14 @@ package server import ( + "fmt" "net/http" "time" "github.com/gorilla/mux" "github.com/improbable-eng/grpc-web/go/grpcweb" "github.com/spf13/cobra" - log "github.com/xlab/suplog" + mintlog "github.com/tharsis/ethermint/log" sdkserver "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/types" @@ -51,15 +52,14 @@ func ConnectTmWS(tmRPCAddr, tmEndpoint string) *rpcclient.WSClient { rpcclient.WriteWait(120*time.Second), rpcclient.PingPeriod(50*time.Second), rpcclient.OnReconnect(func() { - log.WithField("tendermint_rpc", tmRPCAddr+tmEndpoint). - Debugln("EVM RPC reconnects to Tendermint WS") + (*mintlog.EthermintLoggerInstance.TendermintLogger).Debug(fmt.Sprintf("EVM RPC reconnects to Tendermint WS %s", tmRPCAddr+tmEndpoint)) }), ) if err != nil { - log.WithError(err).Fatalln("Tendermint WS client could not be created for ", tmRPCAddr+tmEndpoint) + (*mintlog.EthermintLoggerInstance.TendermintLogger).Error(fmt.Sprintf("Tendermint WS client could not be created for %s, Error %v", tmRPCAddr+tmEndpoint, err)) } else if err := tmWsClient.OnStart(); err != nil { - log.WithError(err).Fatalln("Tendermint WS client could not start for ", tmRPCAddr+tmEndpoint) + (*mintlog.EthermintLoggerInstance.TendermintLogger).Error(fmt.Sprintf("Tendermint WS client could not start for %s, Error %v", tmRPCAddr+tmEndpoint, err)) } return tmWsClient @@ -71,7 +71,8 @@ func MountGRPCWebServices( grpcResources []string, ) { for _, res := range grpcResources { - log.Printf("[GRPC Web] HTTP POST mounted on %s", res) + + (*mintlog.EthermintLoggerInstance.TendermintLogger).Info(fmt.Sprintf("[GRPC Web] HTTP POST mounted on %s", res)) s := router.Methods("POST").Subrouter() s.HandleFunc(res, func(resp http.ResponseWriter, req *http.Request) { diff --git a/x/evm/handler.go b/x/evm/handler.go index 21ae7abc08..9e6f2ca51d 100644 --- a/x/evm/handler.go +++ b/x/evm/handler.go @@ -1,9 +1,10 @@ package evm import ( + "fmt" "runtime/debug" - log "github.com/xlab/suplog" + mintlog "github.com/tharsis/ethermint/log" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -36,10 +37,11 @@ func Recover(err *error) { *err = sdkerrors.Wrapf(sdkerrors.ErrPanic, "%v", r) if e, ok := r.(error); ok { - log.WithError(e).Errorln("evm msg handler panicked with an error") - log.Debugln(string(debug.Stack())) + + (*mintlog.EthermintLoggerInstance.TendermintLogger).Error(fmt.Sprintf("evm msg handler panicked with an error %v", e)) + (*mintlog.EthermintLoggerInstance.TendermintLogger).Debug(string(debug.Stack())) } else { - log.Errorln(r) + (*mintlog.EthermintLoggerInstance.TendermintLogger).Error(fmt.Sprintf("%v", r)) } } } diff --git a/x/evm/types/utils.go b/x/evm/types/utils.go index 5bfca98130..d277c0c138 100644 --- a/x/evm/types/utils.go +++ b/x/evm/types/utils.go @@ -3,14 +3,13 @@ package types import ( "fmt" - log "github.com/xlab/suplog" - "github.com/gogo/protobuf/proto" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/crypto" + mintlog "github.com/tharsis/ethermint/log" ) var EmptyCodeHash = crypto.Keccak256(nil) @@ -19,7 +18,7 @@ var EmptyCodeHash = crypto.Keccak256(nil) func DecodeTxResponse(in []byte) (*MsgEthereumTxResponse, error) { var txMsgData sdk.TxMsgData if err := proto.Unmarshal(in, &txMsgData); err != nil { - log.WithError(err).Errorln("failed to unmarshal TxMsgData") + (*mintlog.EthermintLoggerInstance.TendermintLogger).Error(fmt.Sprintf("failed to unmarshal TxMsgData %v", err)) return nil, err }