Skip to content

Commit

Permalink
fix: ebrelayer log
Browse files Browse the repository at this point in the history
  • Loading branch information
yxq authored and vipwzw committed Sep 15, 2021
1 parent b0d426c commit a8ee06d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
19 changes: 9 additions & 10 deletions plugin/dapp/cross2eth/ebrelayer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
relayerTypes "github.com/33cn/plugin/plugin/dapp/cross2eth/ebrelayer/types"
tml "github.com/BurntSushi/toml"
"github.com/btcsuite/btcd/limits"
"github.com/prometheus/common/log"
)

var (
Expand Down Expand Up @@ -56,26 +55,26 @@ func main() {
if err != nil {
panic(err)
}
log.Info("current dir:", "dir", d)
mainlog.Info("current dir:", "dir", d)
err = limits.SetLimits()
if err != nil {
panic(err)
}
cfg := initCfg(*configPath)
log.Info("Starting FUZAMEI Chain33-X-Ethereum relayer software:", "\n Name: ", cfg.Title)
mainlog.Info("Starting FUZAMEI Chain33-X-Ethereum relayer software:", "\n Name: ", cfg.Title)
logf.SetFileLog(convertLogCfg(cfg.Log))

ctx, cancel := context.WithCancel(context.Background())
var wg sync.WaitGroup
log.Info("db info:", " Dbdriver = ", cfg.SyncTxConfig.Dbdriver, ", DbPath = ", cfg.SyncTxConfig.DbPath, ", DbCache = ", cfg.SyncTxConfig.DbCache)
log.Info("deploy info:", "BridgeRegistry", cfg.BridgeRegistry)
mainlog.Info("db info:", " Dbdriver = ", cfg.SyncTxConfig.Dbdriver, ", DbPath = ", cfg.SyncTxConfig.DbPath, ", DbCache = ", cfg.SyncTxConfig.DbCache)
mainlog.Info("deploy info:", "BridgeRegistry", cfg.BridgeRegistry)
mainlog.Info("db info:", " Dbdriver = ", cfg.SyncTxConfig.Dbdriver, ", DbPath = ", cfg.SyncTxConfig.DbPath, ", DbCache = ", cfg.SyncTxConfig.DbCache)
db := dbm.NewDB("relayer_db_service", cfg.SyncTxConfig.Dbdriver, cfg.SyncTxConfig.DbPath, cfg.SyncTxConfig.DbCache)

ethBridgeClaimChan := make(chan *ebrelayerTypes.EthBridgeClaim, 100)
chain33MsgChan := make(chan *events.Chain33Msg, 100)

log.Info("deploy info for chain33:", "cfg.Deploy4Chain33", cfg.Deploy4Chain33)
mainlog.Info("deploy info for chain33:", "cfg.Deploy4Chain33", cfg.Deploy4Chain33)
chain33StartPara := &chain33Relayer.Chain33StartPara{
ChainName: cfg.ChainName,
Ctx: ctx,
Expand Down Expand Up @@ -103,7 +102,7 @@ func main() {

relayerManager := relayer.NewRelayerManager(chain33RelayerService, ethRelayerService, db)

log.Info("cfg.JrpcBindAddr = ", cfg.JrpcBindAddr)
mainlog.Info("cfg.JrpcBindAddr = ", cfg.JrpcBindAddr)
startRPCServer(cfg.JrpcBindAddr, relayerManager)

ch := make(chan os.Signal, 1)
Expand Down Expand Up @@ -177,10 +176,10 @@ type RPCServer struct {

//ServeHTTP ...
func (r *RPCServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
log.Info("ServeHTTP", "request address", req.RemoteAddr)
mainlog.Info("ServeHTTP", "request address", req.RemoteAddr)
if !IsIPWhiteListEmpty() {
if !IsInIPWhitelist(req.RemoteAddr) {
log.Info("ServeHTTP", "refuse connect address", req.RemoteAddr)
mainlog.Info("ServeHTTP", "refuse connect address", req.RemoteAddr)
w.WriteHeader(401)
return
}
Expand Down Expand Up @@ -224,7 +223,7 @@ func startRPCServer(address string, api interface{}) {
w.WriteHeader(200)
err := srv.ServeRequest(serverCodec)
if err != nil {
log.Debug("http", "Error while serving JSON request: %v", err)
mainlog.Debug("http", "Error while serving JSON request: %v", err)
return
}
}
Expand Down
17 changes: 8 additions & 9 deletions plugin/dapp/x2ethereum/ebrelayer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
relayerTypes "github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/types"
tml "github.com/BurntSushi/toml"
"github.com/btcsuite/btcd/limits"
"github.com/prometheus/common/log"
)

var (
Expand Down Expand Up @@ -54,19 +53,19 @@ func main() {
if err != nil {
panic(err)
}
log.Info("current dir:", "dir", d)
mainlog.Info("current dir:", "dir", d)
err = limits.SetLimits()
if err != nil {
panic(err)
}
cfg := initCfg(*configPath)
log.Info("Starting FUZAMEI Chain33-X-Ethereum relayer software:", "\n Name: ", cfg.Title)
mainlog.Info("Starting FUZAMEI Chain33-X-Ethereum relayer software:", "\n Name: ", cfg.Title)
logf.SetFileLog(convertLogCfg(cfg.Log))

ctx, cancel := context.WithCancel(context.Background())
var wg sync.WaitGroup
log.Info("db info:", " Dbdriver = ", cfg.SyncTxConfig.Dbdriver, ", DbPath = ", cfg.SyncTxConfig.DbPath, ", DbCache = ", cfg.SyncTxConfig.DbCache)
log.Info("deploy info:", "BridgeRegistry", cfg.BridgeRegistry)
mainlog.Info("db info:", " Dbdriver = ", cfg.SyncTxConfig.Dbdriver, ", DbPath = ", cfg.SyncTxConfig.DbPath, ", DbCache = ", cfg.SyncTxConfig.DbCache)
mainlog.Info("deploy info:", "BridgeRegistry", cfg.BridgeRegistry)
mainlog.Info("db info:", " Dbdriver = ", cfg.SyncTxConfig.Dbdriver, ", DbPath = ", cfg.SyncTxConfig.DbPath, ", DbCache = ", cfg.SyncTxConfig.DbCache)
db := dbm.NewDB("relayer_db_service", cfg.SyncTxConfig.Dbdriver, cfg.SyncTxConfig.DbPath, cfg.SyncTxConfig.DbCache)

Expand All @@ -75,7 +74,7 @@ func main() {

relayerManager := relayer.NewRelayerManager(chain33RelayerService, ethRelayerService, db)

log.Info("cfg.JrpcBindAddr = ", cfg.JrpcBindAddr)
mainlog.Info("cfg.JrpcBindAddr = ", cfg.JrpcBindAddr)
startRPCServer(cfg.JrpcBindAddr, relayerManager)

ch := make(chan os.Signal, 1)
Expand Down Expand Up @@ -149,10 +148,10 @@ type RPCServer struct {

//ServeHTTP ...
func (r *RPCServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
log.Info("ServeHTTP", "request address", req.RemoteAddr)
mainlog.Info("ServeHTTP", "request address", req.RemoteAddr)
if !IsIPWhiteListEmpty() {
if !IsInIPWhitelist(req.RemoteAddr) {
log.Info("ServeHTTP", "refuse connect address", req.RemoteAddr)
mainlog.Info("ServeHTTP", "refuse connect address", req.RemoteAddr)
w.WriteHeader(401)
return
}
Expand Down Expand Up @@ -196,7 +195,7 @@ func startRPCServer(address string, api interface{}) {
w.WriteHeader(200)
err := srv.ServeRequest(serverCodec)
if err != nil {
log.Debug("http", "Error while serving JSON request: %v", err)
mainlog.Debug("http", "Error while serving JSON request: %v", err)
return
}
}
Expand Down

0 comments on commit a8ee06d

Please sign in to comment.