forked from cerc-io/laconicd-deprecated
imp: redirect go-ethereum's logs to cosmos logger (#948)
* redirect go-ethereum's logs to cosmos logger Closes: #862 Map go-ethereum's log levels to cosmos ones: trace -> debug debug -> debug info -> info warn -> info error -> error crit -> error * changelog * Apply suggestions from code review * Apply suggestions from code review
This commit is contained in:
parent
0f5b1aa929
commit
dcd2891b73
@ -35,6 +35,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- (log) [#948](https://github.com/tharsis/ethermint/pull/948) redirect go-ethereum's logs to cosmos-sdk logger.
|
||||||
|
|
||||||
## [v0.10.0-beta1] - 2022-02-15
|
## [v0.10.0-beta1] - 2022-02-15
|
||||||
|
|
||||||
### API Breaking
|
### API Breaking
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/server"
|
"github.com/cosmos/cosmos-sdk/server"
|
||||||
"github.com/cosmos/cosmos-sdk/server/types"
|
"github.com/cosmos/cosmos-sdk/server/types"
|
||||||
|
ethlog "github.com/ethereum/go-ethereum/log"
|
||||||
ethrpc "github.com/ethereum/go-ethereum/rpc"
|
ethrpc "github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/tharsis/ethermint/rpc"
|
"github.com/tharsis/ethermint/rpc"
|
||||||
|
|
||||||
@ -20,6 +21,19 @@ import (
|
|||||||
func StartJSONRPC(ctx *server.Context, clientCtx client.Context, tmRPCAddr, tmEndpoint string, config config.Config) (*http.Server, chan struct{}, error) {
|
func StartJSONRPC(ctx *server.Context, clientCtx client.Context, tmRPCAddr, tmEndpoint string, config config.Config) (*http.Server, chan struct{}, error) {
|
||||||
tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, ctx.Logger)
|
tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, ctx.Logger)
|
||||||
|
|
||||||
|
logger := ctx.Logger.With("module", "geth")
|
||||||
|
ethlog.Root().SetHandler(ethlog.FuncHandler(func(r *ethlog.Record) error {
|
||||||
|
switch r.Lvl {
|
||||||
|
case ethlog.LvlTrace, ethlog.LvlDebug:
|
||||||
|
logger.Debug(r.Msg, r.Ctx...)
|
||||||
|
case ethlog.LvlInfo, ethlog.LvlWarn:
|
||||||
|
logger.Info(r.Msg, r.Ctx...)
|
||||||
|
case ethlog.LvlError, ethlog.LvlCrit:
|
||||||
|
logger.Error(r.Msg, r.Ctx...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}))
|
||||||
|
|
||||||
rpcServer := ethrpc.NewServer()
|
rpcServer := ethrpc.NewServer()
|
||||||
|
|
||||||
rpcAPIArr := config.JSONRPC.API
|
rpcAPIArr := config.JSONRPC.API
|
||||||
|
Loading…
Reference in New Issue
Block a user