diff --git a/config/example_config.toml b/config/example_config.toml index 1c584eb15..f9d1f05a0 100644 --- a/config/example_config.toml +++ b/config/example_config.toml @@ -168,6 +168,7 @@ # 'trace', 'debug', 'info', 'warn', and 'error'. [logger.levels] _consensus = 'warn' + _firewall = 'warn' _grpc = 'info' _http = 'info' _jsonrpc = 'info' diff --git a/sync/firewall/firewall.go b/sync/firewall/firewall.go index 278fdbf55..ce67715f6 100644 --- a/sync/firewall/firewall.go +++ b/sync/firewall/firewall.go @@ -32,7 +32,6 @@ type Firewall struct { } func NewFirewall(conf *Config, network network.Network, peerSet *peerset.PeerSet, state state.Facade, - log *logger.SubLogger, ) (*Firewall, error) { blocker, err := ipblocker.New(conf.BannedNets) if err != nil { @@ -52,7 +51,7 @@ func NewFirewall(conf *Config, network network.Network, peerSet *peerset.PeerSet blockRateLimit: blockRateLimit, transactionRateLimit: transactionRateLimit, consensusRateLimit: consensusRateLimit, - logger: log, + logger: logger.NewSubLogger("_firewall", nil), }, nil } diff --git a/sync/firewall/firewall_test.go b/sync/firewall/firewall_test.go index 57998996b..7b0b0b437 100644 --- a/sync/firewall/firewall_test.go +++ b/sync/firewall/firewall_test.go @@ -14,7 +14,6 @@ import ( "github.com/pactus-project/pactus/sync/peerset/peer" "github.com/pactus-project/pactus/sync/peerset/peer/status" "github.com/pactus-project/pactus/util" - "github.com/pactus-project/pactus/util/logger" "github.com/pactus-project/pactus/util/testsuite" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -36,7 +35,6 @@ func setup(t *testing.T, conf *Config) *testData { ts := testsuite.NewTestSuite(t) - subLogger := logger.NewSubLogger("firewall", nil) peerSet := peerset.NewPeerSet(1 * time.Minute) state := state.MockingState(ts) net := network.MockingNetwork(ts, ts.RandPeerID()) @@ -45,7 +43,7 @@ func setup(t *testing.T, conf *Config) *testData { conf = DefaultConfig() } require.NoError(t, conf.BasicCheck()) - firewall, err := NewFirewall(conf, net, peerSet, state, subLogger) + firewall, err := NewFirewall(conf, net, peerSet, state) if err != nil { return nil } diff --git a/sync/sync.go b/sync/sync.go index 58360c2b5..2c824f2f2 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -74,7 +74,7 @@ func NewSynchronizer( sync.peerSet = peerset.NewPeerSet(conf.SessionTimeout()) sync.logger = logger.NewSubLogger("_sync", sync) - fw, err := firewall.NewFirewall(conf.Firewall, network, sync.peerSet, state, sync.logger) + fw, err := firewall.NewFirewall(conf.Firewall, network, sync.peerSet, state) if err != nil { return nil, err } diff --git a/tests/main_test.go b/tests/main_test.go index b5cd10744..4a5aa586a 100644 --- a/tests/main_test.go +++ b/tests/main_test.go @@ -85,6 +85,7 @@ func TestMain(m *testing.M) { tConfigs[i].Logger.Levels["_consensus"] = "info" tConfigs[i].Logger.Levels["_network"] = "info" tConfigs[i].Logger.Levels["_pool"] = "info" + tConfigs[i].Logger.Levels["_firewall"] = "info" tConfigs[i].Sync.Firewall.BannedNets = make([]string, 0) tConfigs[i].Sync.BlockPerSession = 10 tConfigs[i].Network.EnableMdns = true diff --git a/util/logger/config.go b/util/logger/config.go index 6f63a30bc..0d5a47c31 100644 --- a/util/logger/config.go +++ b/util/logger/config.go @@ -29,6 +29,7 @@ func DefaultConfig() *Config { conf.Levels["_grpc"] = "info" conf.Levels["_nonomsg"] = "info" conf.Levels["_jsonrpc"] = "info" + conf.Levels["_firewall"] = "warn" return conf } diff --git a/util/logger/logger.go b/util/logger/logger.go index 03fd0b5a1..48cc1e07d 100644 --- a/util/logger/logger.go +++ b/util/logger/logger.go @@ -54,6 +54,7 @@ func getLoggersInst() *logger { conf.Levels["_pool"] = "debug" conf.Levels["_http"] = "debug" conf.Levels["_grpc"] = "debug" + conf.Levels["_firewall"] = "debug" globalInst = &logger{ config: conf, subs: make(map[string]*SubLogger),