diff --git a/accounts/abi/bind/auth.go b/accounts/abi/bind/auth.go index f44986715..2fa2c1507 100644 --- a/accounts/abi/bind/auth.go +++ b/accounts/abi/bind/auth.go @@ -24,7 +24,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // ErrNoChainID is returned whenever the user failed to specify a chain id. diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 9d7a95aaf..33d7b4c87 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -45,10 +45,10 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/olddb" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/stages" + "github.com/ledgerwatch/log/v3" ) // This nil assignment ensures at compile time that SimulatedBackend implements bind.ContractBackend. diff --git a/accounts/abi/bind/bind.go b/accounts/abi/bind/bind.go index 01d55e09b..9befda58e 100644 --- a/accounts/abi/bind/bind.go +++ b/accounts/abi/bind/bind.go @@ -31,7 +31,7 @@ import ( "unicode" "github.com/ledgerwatch/erigon/accounts/abi" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // Lang is a target programming language selector to generate bindings for. diff --git a/accounts/abi/bind/util.go b/accounts/abi/bind/util.go index d629503d7..970d3215c 100644 --- a/accounts/abi/bind/util.go +++ b/accounts/abi/bind/util.go @@ -23,7 +23,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // WaitMined waits for tx to be mined on the blockchain. diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go index 8db163b8d..b1a3a5214 100644 --- a/cmd/abigen/main.go +++ b/cmd/abigen/main.go @@ -31,8 +31,8 @@ import ( "github.com/ledgerwatch/erigon/common/compiler" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/internal/flags" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" "github.com/urfave/cli" ) @@ -267,7 +267,7 @@ func abigen(c *cli.Context) error { } func main() { - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) if err := app.Run(os.Args); err != nil { fmt.Fprintln(os.Stderr, err) diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go index 0beac16d5..986b8939a 100644 --- a/cmd/bootnode/main.go +++ b/cmd/bootnode/main.go @@ -26,11 +26,11 @@ import ( "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/discover" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/nat" "github.com/ledgerwatch/erigon/p2p/netutil" + "github.com/ledgerwatch/log/v3" ) func main() { @@ -44,17 +44,17 @@ func main() { netrestrict = flag.String("netrestrict", "", "restrict network communication to the given IP networks (CIDR masks)") runv5 = flag.Bool("v5", false, "run a v5 topic discovery bootnode") verbosity = flag.Int("verbosity", int(log.LvlInfo), "log verbosity (0-5)") - vmodule = flag.String("vmodule", "", "log verbosity pattern") + //vmodule = flag.String("vmodule", "", "log verbosity pattern") nodeKey *ecdsa.PrivateKey err error ) flag.Parse() - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.Lvl(*verbosity)) - glogger.Vmodule(*vmodule) - log.Root().SetHandler(glogger) + //glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) + //glogger.Verbosity(log.Lvl(*verbosity)) + //glogger.Vmodule(*vmodule) + log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*verbosity), log.StderrHandler)) natm, err := nat.Parse(*natdesc) if err != nil { diff --git a/cmd/cons/commands/clique.go b/cmd/cons/commands/clique.go index 2b96f0d53..c2b37b2cd 100644 --- a/cmd/cons/commands/clique.go +++ b/cmd/cons/commands/clique.go @@ -25,9 +25,9 @@ import ( "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" "github.com/pelletier/go-toml" "github.com/spf13/cobra" "google.golang.org/grpc" diff --git a/cmd/cons/commands/root.go b/cmd/cons/commands/root.go index 88d2a2f71..b40a187a1 100644 --- a/cmd/cons/commands/root.go +++ b/cmd/cons/commands/root.go @@ -9,7 +9,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/internal/debug" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/devp2p/crawl.go b/cmd/devp2p/crawl.go index 3fb5bdea0..c813e389b 100644 --- a/cmd/devp2p/crawl.go +++ b/cmd/devp2p/crawl.go @@ -20,8 +20,8 @@ import ( "time" "github.com/ledgerwatch/erigon/common/debug" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" + "github.com/ledgerwatch/log/v3" ) type crawler struct { diff --git a/cmd/devp2p/dns_cloudflare.go b/cmd/devp2p/dns_cloudflare.go index 236f025bb..14b4ec185 100644 --- a/cmd/devp2p/dns_cloudflare.go +++ b/cmd/devp2p/dns_cloudflare.go @@ -21,8 +21,8 @@ import ( "strings" "github.com/cloudflare/cloudflare-go" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/dnsdisc" + "github.com/ledgerwatch/log/v3" "github.com/urfave/cli" ) diff --git a/cmd/devp2p/dns_route53.go b/cmd/devp2p/dns_route53.go index 781c950f9..7c71dc99a 100644 --- a/cmd/devp2p/dns_route53.go +++ b/cmd/devp2p/dns_route53.go @@ -27,8 +27,8 @@ import ( "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/route53" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/dnsdisc" + "github.com/ledgerwatch/log/v3" cli "github.com/urfave/cli" ) diff --git a/cmd/devp2p/runtest.go b/cmd/devp2p/runtest.go index 6a6c50a7e..869b7d669 100644 --- a/cmd/devp2p/runtest.go +++ b/cmd/devp2p/runtest.go @@ -21,7 +21,7 @@ import ( "github.com/ledgerwatch/erigon/cmd/devp2p/internal/v4test" "github.com/ledgerwatch/erigon/internal/utesting" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/urfave/cli" ) diff --git a/cmd/erigon/main.go b/cmd/erigon/main.go index 309933e95..d0b04b820 100644 --- a/cmd/erigon/main.go +++ b/cmd/erigon/main.go @@ -10,10 +10,10 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" erigoncli "github.com/ledgerwatch/erigon/turbo/cli" "github.com/ledgerwatch/erigon/turbo/node" + "github.com/ledgerwatch/log/v3" "github.com/urfave/cli" ) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 571b2b1da..e014e79fa 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -32,10 +32,10 @@ import ( "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/memdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/trie" + "github.com/ledgerwatch/log/v3" "golang.org/x/crypto/sha3" ) diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index ba6dbdf4b..923069e3e 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -33,10 +33,10 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/tests" + "github.com/ledgerwatch/log/v3" "github.com/urfave/cli" ) @@ -76,10 +76,13 @@ type input struct { } func Main(ctx *cli.Context) error { - // Configure the go-ethereum logger - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.Lvl(ctx.Int(VerbosityFlag.Name))) - log.Root().SetHandler(glogger) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) + /* + // Configure the go-ethereum logger + glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) + glogger.Verbosity(log.Lvl(ctx.Int(VerbosityFlag.Name))) + log.Root().SetHandler(glogger) + */ var ( err error diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go index 5759b2640..4a237ce02 100644 --- a/cmd/evm/runner.go +++ b/cmd/evm/runner.go @@ -40,8 +40,8 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm/runtime" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) var runCommand = cli.Command{ @@ -107,9 +107,10 @@ func timedExec(bench bool, execFunc func() ([]byte, uint64, error)) (output []by } func runCmd(ctx *cli.Context) error { - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name))) - log.Root().SetHandler(glogger) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) + //glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) + //glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name))) + //log.Root().SetHandler(glogger) logconfig := &vm.LogConfig{ DisableMemory: ctx.GlobalBool(DisableMemoryFlag.Name), DisableStack: ctx.GlobalBool(DisableStackFlag.Name), diff --git a/cmd/evm/staterunner.go b/cmd/evm/staterunner.go index eadd7c8c7..9d1ae2819 100644 --- a/cmd/evm/staterunner.go +++ b/cmd/evm/staterunner.go @@ -28,10 +28,10 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/ethdb/memdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/tests" "github.com/ledgerwatch/erigon/turbo/trie" + "github.com/ledgerwatch/log/v3" "github.com/urfave/cli" ) @@ -57,9 +57,9 @@ func stateTestCmd(ctx *cli.Context) error { return errors.New("path-to-test argument required") } // Configure the go-ethereum logger - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name))) - log.Root().SetHandler(glogger) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) + //glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) + //glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name))) // Configure the EVM logger config := &vm.LogConfig{ diff --git a/cmd/hack/db/lmdb.go b/cmd/hack/db/lmdb.go index 0ccde79aa..1abe74d7b 100644 --- a/cmd/hack/db/lmdb.go +++ b/cmd/hack/db/lmdb.go @@ -18,7 +18,7 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/ethdb/kv" kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) var logger = log.New() diff --git a/cmd/hack/hack.go b/cmd/hack/hack.go index fd78c6d07..e4e5b597b 100644 --- a/cmd/hack/hack.go +++ b/cmd/hack/hack.go @@ -45,10 +45,10 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/migrations" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/trie" + "github.com/ledgerwatch/log/v3" ) var ( @@ -2269,7 +2269,7 @@ func runBlock(ibs *state.IntraBlockState, txnWriter state.StateWriter, blockWrit func main() { flag.Parse() - log.SetupDefaultTerminalLogger(log.Lvl(*verbosity), "", "") + log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*verbosity), log.StderrHandler)) if *cpuprofile != "" { f, err := os.Create(*cpuprofile) diff --git a/cmd/integration/commands/refetence_db.go b/cmd/integration/commands/refetence_db.go index bda7717e9..46f49f5cc 100644 --- a/cmd/integration/commands/refetence_db.go +++ b/cmd/integration/commands/refetence_db.go @@ -13,7 +13,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb/kv" mdbx2 "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" "github.com/torquem-ch/mdbx-go/mdbx" ) diff --git a/cmd/integration/commands/reset_state.go b/cmd/integration/commands/reset_state.go index d86e16b71..5d54aaea4 100644 --- a/cmd/integration/commands/reset_state.go +++ b/cmd/integration/commands/reset_state.go @@ -12,7 +12,7 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/integration/commands/root.go b/cmd/integration/commands/root.go index a55afb43f..0ef9e849e 100644 --- a/cmd/integration/commands/root.go +++ b/cmd/integration/commands/root.go @@ -7,8 +7,8 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/internal/debug" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/migrations" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/integration/commands/snapshot_check.go b/cmd/integration/commands/snapshot_check.go index de5aa63dd..8ee3959fc 100644 --- a/cmd/integration/commands/snapshot_check.go +++ b/cmd/integration/commands/snapshot_check.go @@ -17,8 +17,8 @@ import ( kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/prune" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/turbo/snapshotsync" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/integration/commands/stages.go b/cmd/integration/commands/stages.go index f29f92450..ef357e608 100644 --- a/cmd/integration/commands/stages.go +++ b/cmd/integration/commands/stages.go @@ -24,11 +24,11 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/privateapi" "github.com/ledgerwatch/erigon/ethdb/prune" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/migrations" "github.com/ledgerwatch/erigon/params" stages2 "github.com/ledgerwatch/erigon/turbo/stages" "github.com/ledgerwatch/erigon/turbo/txpool" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/integration/commands/state_stages.go b/cmd/integration/commands/state_stages.go index 7002a464d..b7b99da2e 100644 --- a/cmd/integration/commands/state_stages.go +++ b/cmd/integration/commands/state_stages.go @@ -30,10 +30,10 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/bitmapdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/params" erigoncli "github.com/ledgerwatch/erigon/turbo/cli" + "github.com/ledgerwatch/log/v3" ) var stateStags = &cobra.Command{ diff --git a/cmd/integration/commands/testing.go b/cmd/integration/commands/testing.go index 1ba97887d..cd6e6a449 100644 --- a/cmd/integration/commands/testing.go +++ b/cmd/integration/commands/testing.go @@ -14,8 +14,8 @@ import ( proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry" proto_testing "github.com/ledgerwatch/erigon-lib/gointerfaces/testing" "github.com/ledgerwatch/erigon/cmd/utils" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" "google.golang.org/grpc" "google.golang.org/grpc/keepalive" diff --git a/cmd/pics/state.go b/cmd/pics/state.go index 7693bd4d9..c9b30d49a 100644 --- a/cmd/pics/state.go +++ b/cmd/pics/state.go @@ -21,11 +21,11 @@ import ( "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/memdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/stages" "github.com/ledgerwatch/erigon/turbo/trie" "github.com/ledgerwatch/erigon/visual" + "github.com/ledgerwatch/log/v3" ) /*func statePicture(t *trie.Trie, number int, keyCompression int, codeCompressed bool, valCompressed bool, @@ -260,7 +260,7 @@ func dot2png(dotFileName string) string { func initialState1() error { defer log.Root().SetHandler(log.Root().GetHandler()) - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) fmt.Printf("Initial state 1\n") // Configure and generate a sample block chain var ( diff --git a/cmd/rpcdaemon/cli/config.go b/cmd/rpcdaemon/cli/config.go index 0d2842f8b..f08b6fc0d 100644 --- a/cmd/rpcdaemon/cli/config.go +++ b/cmd/rpcdaemon/cli/config.go @@ -17,9 +17,9 @@ import ( "github.com/ledgerwatch/erigon/ethdb/remotedb" "github.com/ledgerwatch/erigon/ethdb/remotedbserver" "github.com/ledgerwatch/erigon/internal/debug" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/rpcdaemon/commands/eth_block.go b/cmd/rpcdaemon/commands/eth_block.go index 2628179dc..c12652095 100644 --- a/cmd/rpcdaemon/commands/eth_block.go +++ b/cmd/rpcdaemon/commands/eth_block.go @@ -14,11 +14,11 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/adapter/ethapi" "github.com/ledgerwatch/erigon/turbo/rpchelper" "github.com/ledgerwatch/erigon/turbo/transactions" + "github.com/ledgerwatch/log/v3" "golang.org/x/crypto/sha3" ) diff --git a/cmd/rpcdaemon/commands/eth_call.go b/cmd/rpcdaemon/commands/eth_call.go index 1606b573f..917397fcf 100644 --- a/cmd/rpcdaemon/commands/eth_call.go +++ b/cmd/rpcdaemon/commands/eth_call.go @@ -15,10 +15,10 @@ import ( "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/internal/ethapi" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/transactions" + "github.com/ledgerwatch/log/v3" ) // Call implements eth_call. Executes a new message call immediately without creating a transaction on the block chain. diff --git a/cmd/rpcdaemon/commands/eth_filters.go b/cmd/rpcdaemon/commands/eth_filters.go index afa4c44c4..306c86a42 100644 --- a/cmd/rpcdaemon/commands/eth_filters.go +++ b/cmd/rpcdaemon/commands/eth_filters.go @@ -7,8 +7,8 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" ) // NewPendingTransactionFilter new transaction filter diff --git a/cmd/rpcdaemon/commands/eth_system.go b/cmd/rpcdaemon/commands/eth_system.go index 88df9bf10..bbf3d8e63 100644 --- a/cmd/rpcdaemon/commands/eth_system.go +++ b/cmd/rpcdaemon/commands/eth_system.go @@ -10,9 +10,9 @@ import ( "github.com/ledgerwatch/erigon/eth/ethconfig" "github.com/ledgerwatch/erigon/eth/gasprice" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" ) // BlockNumber implements eth_blockNumber. Returns the block number of most recent block. diff --git a/cmd/rpcdaemon/commands/eth_uncles.go b/cmd/rpcdaemon/commands/eth_uncles.go index 81e8b3d36..4e8207e3e 100644 --- a/cmd/rpcdaemon/commands/eth_uncles.go +++ b/cmd/rpcdaemon/commands/eth_uncles.go @@ -7,9 +7,9 @@ import ( "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/adapter/ethapi" + "github.com/ledgerwatch/log/v3" ) // GetUncleByBlockNumberAndIndex implements eth_getUncleByBlockNumberAndIndex. Returns information about an uncle given a block's number and the index of the uncle. diff --git a/cmd/rpcdaemon/commands/send_transaction.go b/cmd/rpcdaemon/commands/send_transaction.go index 6a97981eb..1309638be 100644 --- a/cmd/rpcdaemon/commands/send_transaction.go +++ b/cmd/rpcdaemon/commands/send_transaction.go @@ -14,9 +14,9 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/eth/ethconfig" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) // SendRawTransaction implements eth_sendRawTransaction. Creates new message call transaction or a contract creation for previously-signed transactions. diff --git a/cmd/rpcdaemon/commands/trace_adhoc.go b/cmd/rpcdaemon/commands/trace_adhoc.go index 99335bbad..36e17d9ee 100644 --- a/cmd/rpcdaemon/commands/trace_adhoc.go +++ b/cmd/rpcdaemon/commands/trace_adhoc.go @@ -21,11 +21,11 @@ import ( "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm/stack" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/rpchelper" "github.com/ledgerwatch/erigon/turbo/shards" "github.com/ledgerwatch/erigon/turbo/transactions" + "github.com/ledgerwatch/log/v3" ) const callTimeout = 5 * time.Minute diff --git a/cmd/rpcdaemon/filters/filters.go b/cmd/rpcdaemon/filters/filters.go index bef86f75c..e9cce4a20 100644 --- a/cmd/rpcdaemon/filters/filters.go +++ b/cmd/rpcdaemon/filters/filters.go @@ -14,8 +14,8 @@ import ( "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/services" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/cmd/rpcdaemon/main.go b/cmd/rpcdaemon/main.go index c9b6532b2..917a99992 100644 --- a/cmd/rpcdaemon/main.go +++ b/cmd/rpcdaemon/main.go @@ -8,7 +8,7 @@ import ( "github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common/fdlimit" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/rpcdaemon/services/eth_backend.go b/cmd/rpcdaemon/services/eth_backend.go index a7e82b6f7..6b3a45430 100644 --- a/cmd/rpcdaemon/services/eth_backend.go +++ b/cmd/rpcdaemon/services/eth_backend.go @@ -10,7 +10,7 @@ import ( "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb/privateapi" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" diff --git a/cmd/rpcdaemon/services/eth_mining.go b/cmd/rpcdaemon/services/eth_mining.go index 957180740..0a07cb77f 100644 --- a/cmd/rpcdaemon/services/eth_mining.go +++ b/cmd/rpcdaemon/services/eth_mining.go @@ -7,7 +7,7 @@ import ( "github.com/ledgerwatch/erigon-lib/gointerfaces" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon/ethdb/privateapi" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/cmd/rpcdaemon/services/eth_txpool.go b/cmd/rpcdaemon/services/eth_txpool.go index 87b53ada1..7d4753901 100644 --- a/cmd/rpcdaemon/services/eth_txpool.go +++ b/cmd/rpcdaemon/services/eth_txpool.go @@ -7,7 +7,7 @@ import ( "github.com/ledgerwatch/erigon-lib/gointerfaces" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon/ethdb/privateapi" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/cmd/rpctest/main.go b/cmd/rpctest/main.go index 92aeb1c55..1cca82b2e 100644 --- a/cmd/rpctest/main.go +++ b/cmd/rpctest/main.go @@ -8,12 +8,12 @@ import ( "syscall" "github.com/ledgerwatch/erigon/cmd/rpctest/rpctest" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) func main() { - log.SetupDefaultTerminalLogger(log.Lvl(3), "", "") + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) var ( needCompare bool diff --git a/cmd/rpctest/rpctest/account_range_verify.go b/cmd/rpctest/rpctest/account_range_verify.go index f5579fca5..7e7a41f60 100644 --- a/cmd/rpctest/rpctest/account_range_verify.go +++ b/cmd/rpctest/rpctest/account_range_verify.go @@ -15,7 +15,7 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) func CompareAccountRange(logger log.Logger, erigonURL, gethURL, tmpDataDir, gethDataDir string, blockFrom uint64, notRegenerateGethData bool) { diff --git a/cmd/rpctest/rpctest/utils.go b/cmd/rpctest/rpctest/utils.go index 1a950b8b1..18c09c3b6 100644 --- a/cmd/rpctest/rpctest/utils.go +++ b/cmd/rpctest/rpctest/utils.go @@ -13,7 +13,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/valyala/fastjson" ) diff --git a/cmd/sentry/download/broadcast.go b/cmd/sentry/download/broadcast.go index 40d71332e..552afbd42 100644 --- a/cmd/sentry/download/broadcast.go +++ b/cmd/sentry/download/broadcast.go @@ -10,9 +10,9 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/protocols/eth" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" ) diff --git a/cmd/sentry/download/downloader.go b/cmd/sentry/download/downloader.go index eec5975a4..4ba51463c 100644 --- a/cmd/sentry/download/downloader.go +++ b/cmd/sentry/download/downloader.go @@ -20,12 +20,12 @@ import ( "github.com/ledgerwatch/erigon/core/forkid" "github.com/ledgerwatch/erigon/eth/protocols/eth" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/remote" "github.com/ledgerwatch/erigon/turbo/stages/bodydownload" "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/grpc/backoff" "google.golang.org/grpc/codes" diff --git a/cmd/sentry/download/sentry.go b/cmd/sentry/download/sentry.go index b7f2474d3..9d545ff00 100644 --- a/cmd/sentry/download/sentry.go +++ b/cmd/sentry/download/sentry.go @@ -28,13 +28,13 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/core/forkid" "github.com/ledgerwatch/erigon/eth/protocols/eth" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/p2p/dnsdisc" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/grpc/keepalive" ) diff --git a/cmd/sentry/download/sentry_api.go b/cmd/sentry/download/sentry_api.go index aaacc1c1c..a45bb5ba3 100644 --- a/cmd/sentry/download/sentry_api.go +++ b/cmd/sentry/download/sentry_api.go @@ -9,10 +9,10 @@ import ( proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/eth/protocols/eth" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/stages/bodydownload" "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" ) diff --git a/cmd/snapshots/debug/debug_test.go b/cmd/snapshots/debug/debug_test.go index 84d63c570..f9596c7f4 100644 --- a/cmd/snapshots/debug/debug_test.go +++ b/cmd/snapshots/debug/debug_test.go @@ -22,8 +22,8 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/cmd/snapshots/downloader/commands/root.go b/cmd/snapshots/downloader/commands/root.go index 97208d12f..eaf659270 100644 --- a/cmd/snapshots/downloader/commands/root.go +++ b/cmd/snapshots/downloader/commands/root.go @@ -14,9 +14,9 @@ import ( grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/internal/debug" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/snapshotsync" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" "github.com/urfave/cli" "google.golang.org/grpc" diff --git a/cmd/snapshots/generator/commands/copy_from_state.go b/cmd/snapshots/generator/commands/copy_from_state.go index 9871a5941..55ca97075 100644 --- a/cmd/snapshots/generator/commands/copy_from_state.go +++ b/cmd/snapshots/generator/commands/copy_from_state.go @@ -8,7 +8,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/snapshots/generator/commands/generate_body_snapshot.go b/cmd/snapshots/generator/commands/generate_body_snapshot.go index 698e4c1b5..1e88cd667 100644 --- a/cmd/snapshots/generator/commands/generate_body_snapshot.go +++ b/cmd/snapshots/generator/commands/generate_body_snapshot.go @@ -13,7 +13,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/rawdb" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) func init() { diff --git a/cmd/snapshots/generator/commands/generate_header_snapshot.go b/cmd/snapshots/generator/commands/generate_header_snapshot.go index f8abb58b5..0c24cfa90 100644 --- a/cmd/snapshots/generator/commands/generate_header_snapshot.go +++ b/cmd/snapshots/generator/commands/generate_header_snapshot.go @@ -14,7 +14,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/rawdb" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) func init() { diff --git a/cmd/snapshots/generator/commands/generate_state_snapshot.go b/cmd/snapshots/generator/commands/generate_state_snapshot.go index 7441d3046..08f900d72 100644 --- a/cmd/snapshots/generator/commands/generate_state_snapshot.go +++ b/cmd/snapshots/generator/commands/generate_state_snapshot.go @@ -14,8 +14,8 @@ import ( "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/turbo/trie" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/snapshots/generator/commands/root.go b/cmd/snapshots/generator/commands/root.go index e7d8b74b3..273106e21 100644 --- a/cmd/snapshots/generator/commands/root.go +++ b/cmd/snapshots/generator/commands/root.go @@ -11,7 +11,7 @@ import ( "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common/paths" "github.com/ledgerwatch/erigon/internal/debug" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/snapshots/generator/commands/verify_headers.go b/cmd/snapshots/generator/commands/verify_headers.go index c042a989a..df1dfdb3a 100644 --- a/cmd/snapshots/generator/commands/verify_headers.go +++ b/cmd/snapshots/generator/commands/verify_headers.go @@ -8,9 +8,9 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/snapshotsync" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/snapshots/generator/commands/verify_state_snapshot.go b/cmd/snapshots/generator/commands/verify_state_snapshot.go index b772b62da..aef481b31 100644 --- a/cmd/snapshots/generator/commands/verify_state_snapshot.go +++ b/cmd/snapshots/generator/commands/verify_state_snapshot.go @@ -12,7 +12,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/snapshots/seeder/commands/root.go b/cmd/snapshots/seeder/commands/root.go index 77867d95f..eb65cd03c 100644 --- a/cmd/snapshots/seeder/commands/root.go +++ b/cmd/snapshots/seeder/commands/root.go @@ -9,7 +9,7 @@ import ( "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/internal/debug" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/snapshots/seeder/commands/seeder.go b/cmd/snapshots/seeder/commands/seeder.go index 09990e1ea..add8940a0 100644 --- a/cmd/snapshots/seeder/commands/seeder.go +++ b/cmd/snapshots/seeder/commands/seeder.go @@ -12,8 +12,8 @@ import ( "github.com/anacrolix/torrent/bencode" "github.com/anacrolix/torrent/metainfo" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/log" trnt "github.com/ledgerwatch/erigon/turbo/snapshotsync" + "github.com/ledgerwatch/log/v3" ) func Seed(ctx context.Context, datadir string) error { diff --git a/cmd/snapshots/tracker/commands/root.go b/cmd/snapshots/tracker/commands/root.go index 5d3e1f27e..23f11df78 100644 --- a/cmd/snapshots/tracker/commands/root.go +++ b/cmd/snapshots/tracker/commands/root.go @@ -22,7 +22,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/internal/debug" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/snapshots/utils/utils.go b/cmd/snapshots/utils/utils.go index b8286e249..0bfea7b85 100644 --- a/cmd/snapshots/utils/utils.go +++ b/cmd/snapshots/utils/utils.go @@ -6,7 +6,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) var ErrUnsupported error = errors.New("unsupported KV type") diff --git a/cmd/state/commands/check_change_sets.go b/cmd/state/commands/check_change_sets.go index 3ba7fcdf3..1363214b7 100644 --- a/cmd/state/commands/check_change_sets.go +++ b/cmd/state/commands/check_change_sets.go @@ -21,7 +21,7 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/state/commands/opcode_tracer.go b/cmd/state/commands/opcode_tracer.go index a25657ce3..cf86db05b 100644 --- a/cmd/state/commands/opcode_tracer.go +++ b/cmd/state/commands/opcode_tracer.go @@ -25,8 +25,8 @@ import ( "github.com/ledgerwatch/erigon/core/vm/stack" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/state/commands/root.go b/cmd/state/commands/root.go index ef5fcb1bc..e1cece986 100644 --- a/cmd/state/commands/root.go +++ b/cmd/state/commands/root.go @@ -12,7 +12,7 @@ import ( "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/internal/debug" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/state/commands/verify_headers_snapshot.go b/cmd/state/commands/verify_headers_snapshot.go index f2ab66472..92395320b 100644 --- a/cmd/state/commands/verify_headers_snapshot.go +++ b/cmd/state/commands/verify_headers_snapshot.go @@ -2,7 +2,7 @@ package commands import ( "github.com/ledgerwatch/erigon/cmd/state/verify" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" ) diff --git a/cmd/state/generate/regenerate_tx_lookup.go b/cmd/state/generate/regenerate_tx_lookup.go index 954ef93e0..3f98e74aa 100644 --- a/cmd/state/generate/regenerate_tx_lookup.go +++ b/cmd/state/generate/regenerate_tx_lookup.go @@ -12,7 +12,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/prune" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) func RegenerateTxLookup(chaindata string) error { diff --git a/cmd/state/verify/verify_headers_snapshot.go b/cmd/state/verify/verify_headers_snapshot.go index f1840b024..67f0b9d88 100644 --- a/cmd/state/verify/verify_headers_snapshot.go +++ b/cmd/state/verify/verify_headers_snapshot.go @@ -7,8 +7,8 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) func HeadersSnapshot(logger log.Logger, snapshotPath string) error { diff --git a/cmd/state/verify/verify_txlookup.go b/cmd/state/verify/verify_txlookup.go index 8cd410786..73c30c536 100644 --- a/cmd/state/verify/verify_txlookup.go +++ b/cmd/state/verify/verify_txlookup.go @@ -13,7 +13,7 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) func ValidateTxLookups(chaindata string) error { diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index 302663c5f..27577b7a5 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -31,8 +31,8 @@ import ( _debug "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/internal/debug" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" + "github.com/ledgerwatch/log/v3" ) // Fatalf formats a message to standard error and exits the program. diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index e1d8550c9..12cfffd6f 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -44,7 +44,6 @@ import ( "github.com/ledgerwatch/erigon/eth/ethconfig" "github.com/ledgerwatch/erigon/eth/gasprice" "github.com/ledgerwatch/erigon/internal/flags" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/p2p" @@ -52,6 +51,7 @@ import ( "github.com/ledgerwatch/erigon/p2p/nat" "github.com/ledgerwatch/erigon/p2p/netutil" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) func init() { diff --git a/common/debug/log_panic.go b/common/debug/log_panic.go index 3f7d4c2c6..ef863f1ea 100644 --- a/common/debug/log_panic.go +++ b/common/debug/log_panic.go @@ -7,7 +7,7 @@ import ( "strings" "syscall" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) var sigc chan os.Signal diff --git a/common/etl/collector.go b/common/etl/collector.go index ffaf823db..360fb43b5 100644 --- a/common/etl/collector.go +++ b/common/etl/collector.go @@ -14,7 +14,7 @@ import ( "github.com/c2h5oh/datasize" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/ugorji/go/codec" ) diff --git a/common/etl/dataprovider.go b/common/etl/dataprovider.go index c63042e28..04adf7c87 100644 --- a/common/etl/dataprovider.go +++ b/common/etl/dataprovider.go @@ -9,7 +9,7 @@ import ( "runtime" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) type dataProvider interface { diff --git a/common/etl/etl.go b/common/etl/etl.go index 0a7ff828f..b1114ebd9 100644 --- a/common/etl/etl.go +++ b/common/etl/etl.go @@ -12,7 +12,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/ugorji/go/codec" ) diff --git a/consensus/aura/aura.go b/consensus/aura/aura.go index cead2e9aa..c30befd86 100644 --- a/consensus/aura/aura.go +++ b/consensus/aura/aura.go @@ -38,10 +38,10 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/secp256k1" "go.uber.org/atomic" ) diff --git a/consensus/aura/validators.go b/consensus/aura/validators.go index 651440455..bab7e6759 100644 --- a/consensus/aura/validators.go +++ b/consensus/aura/validators.go @@ -17,8 +17,8 @@ import ( "github.com/ledgerwatch/erigon/consensus/aura/aurainterfaces" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" "go.uber.org/atomic" ) diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 9773048e7..88e0e888b 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -41,10 +41,10 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/consensus/clique/snapshot.go b/consensus/clique/snapshot.go index cc57d8ce0..20012de63 100644 --- a/consensus/clique/snapshot.go +++ b/consensus/clique/snapshot.go @@ -31,8 +31,8 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) // Vote represents a single vote that an authorized signer made to modify the diff --git a/consensus/clique/verifier.go b/consensus/clique/verifier.go index e3d9fbb47..5c4143602 100644 --- a/consensus/clique/verifier.go +++ b/consensus/clique/verifier.go @@ -9,8 +9,8 @@ import ( "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus/misc" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) // verifyHeader checks whether a header conforms to the consensus rules.The diff --git a/consensus/db/db.go b/consensus/db/db.go index 17705e902..89ee07786 100644 --- a/consensus/db/db.go +++ b/consensus/db/db.go @@ -3,7 +3,7 @@ package db import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) func OpenDatabase(path string, logger log.Logger, inmem bool) kv.RwDB { diff --git a/consensus/ethash/algorithm.go b/consensus/ethash/algorithm.go index befd741dd..cc423ad43 100644 --- a/consensus/ethash/algorithm.go +++ b/consensus/ethash/algorithm.go @@ -33,7 +33,7 @@ import ( "github.com/ledgerwatch/erigon/common/bitutil" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index d3fbb5e59..2029d7304 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -36,9 +36,9 @@ import ( "github.com/ledgerwatch/erigon/consensus/misc" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" "golang.org/x/crypto/sha3" ) diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go index 47b1dbaf0..042ca99f0 100644 --- a/consensus/ethash/ethash.go +++ b/consensus/ethash/ethash.go @@ -36,9 +36,9 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/consensus" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" ) const doNotStoreCachesOnDisk = "" diff --git a/consensus/ethash/fake.go b/consensus/ethash/fake.go index 132952e58..da98aa892 100644 --- a/consensus/ethash/fake.go +++ b/consensus/ethash/fake.go @@ -8,7 +8,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) type FakeEthash struct { diff --git a/consensus/ethash/sealer_test.go b/consensus/ethash/sealer_test.go index 70fe46723..1691f0753 100644 --- a/consensus/ethash/sealer_test.go +++ b/consensus/ethash/sealer_test.go @@ -30,7 +30,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/internal/testlog" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // Tests whether remote HTTP servers are correctly notified of new work. diff --git a/consensus/result.go b/consensus/result.go index 5f94b87a0..a1e3dfa74 100644 --- a/consensus/result.go +++ b/consensus/result.go @@ -5,7 +5,7 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) type ResultWithContext struct { diff --git a/core/blockchain.go b/core/blockchain.go index 25a956ba2..71a9d969f 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -32,9 +32,9 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/core/vm" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) var ( diff --git a/core/forkid/forkid.go b/core/forkid/forkid.go index a721508b5..73f26f408 100644 --- a/core/forkid/forkid.go +++ b/core/forkid/forkid.go @@ -28,8 +28,8 @@ import ( "strings" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) var ( diff --git a/core/genesis.go b/core/genesis.go index f9301bf21..e6ab96afa 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -38,10 +38,10 @@ import ( "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/trie" + "github.com/ledgerwatch/log/v3" ) //go:generate gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index af74d9428..7db1c566a 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -28,8 +28,8 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/cbor" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) // ReadCanonicalHash retrieves the hash assigned to a canonical block number. diff --git a/core/rawdb/accessors_indexes.go b/core/rawdb/accessors_indexes.go index 9147f4feb..ae6e82b4e 100644 --- a/core/rawdb/accessors_indexes.go +++ b/core/rawdb/accessors_indexes.go @@ -22,7 +22,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // TxLookupEntry is a positional metadata to help looking up the data content of diff --git a/core/state/intra_block_state.go b/core/state/intra_block_state.go index d695b97b0..5c3939fe8 100644 --- a/core/state/intra_block_state.go +++ b/core/state/intra_block_state.go @@ -27,9 +27,9 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/trie" + "github.com/ledgerwatch/log/v3" ) type revision struct { diff --git a/core/state/plain_readonly.go b/core/state/plain_readonly.go index b89599089..e577d84d6 100644 --- a/core/state/plain_readonly.go +++ b/core/state/plain_readonly.go @@ -25,7 +25,7 @@ import ( "github.com/ledgerwatch/erigon/common/dbutils" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/petar/GoLLRB/llrb" ) diff --git a/core/tx_journal.go b/core/tx_journal.go index eb71192f1..8631058c6 100644 --- a/core/tx_journal.go +++ b/core/tx_journal.go @@ -24,8 +24,8 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) // errNoActiveJournal is returned if a transaction is attempted to be inserted diff --git a/core/tx_pool.go b/core/tx_pool.go index a8c231fbf..35dd1901d 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -33,9 +33,9 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/olddb" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 3ee75d643..53f672da6 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -24,8 +24,8 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) func opAdd(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) { diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 52fd9ede3..78b3e0358 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -23,7 +23,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/math" "github.com/ledgerwatch/erigon/core/vm/stack" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // Config are the configuration options for the Interpreter diff --git a/docs/readthedocs/source/rpc/tutorial.rst b/docs/readthedocs/source/rpc/tutorial.rst index 5a34dc486..76000f363 100644 --- a/docs/readthedocs/source/rpc/tutorial.rst +++ b/docs/readthedocs/source/rpc/tutorial.rst @@ -56,7 +56,7 @@ Now we are going to make our `main.go` where we are going to serve the api we ma "github.com/ledgerwatch/erigon/cmd/utils" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon/rpc" "github.com/spf13/cobra" ) diff --git a/eth/backend.go b/eth/backend.go index 1431e9647..43fdbed4b 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -56,7 +56,6 @@ import ( "github.com/ledgerwatch/erigon/ethdb/privateapi" "github.com/ledgerwatch/erigon/ethdb/prune" remotedbserver2 "github.com/ledgerwatch/erigon/ethdb/remotedbserver" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/params" @@ -67,6 +66,7 @@ import ( stages2 "github.com/ledgerwatch/erigon/turbo/stages" "github.com/ledgerwatch/erigon/turbo/stages/txpropagate" "github.com/ledgerwatch/erigon/turbo/txpool" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/grpc/credentials" ) diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 4738f3e4b..38a66aebf 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -38,9 +38,9 @@ import ( "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/eth/gasprice" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/snapshotsync" + "github.com/ledgerwatch/log/v3" ) // FullNodeGPO contains default gasprice oracle settings for full node. diff --git a/eth/ethutils/utils.go.go b/eth/ethutils/utils.go.go index 8676815ff..cdc3368f4 100644 --- a/eth/ethutils/utils.go.go +++ b/eth/ethutils/utils.go.go @@ -4,7 +4,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // IsLocalBlock checks whether the specified block is mined diff --git a/eth/fetcher/block_fetcher.go b/eth/fetcher/block_fetcher.go index 5436dfaec..4df1f219d 100644 --- a/eth/fetcher/block_fetcher.go +++ b/eth/fetcher/block_fetcher.go @@ -27,7 +27,7 @@ import ( "github.com/ledgerwatch/erigon/common/prque" "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/eth/fetcher/tx_fetcher.go b/eth/fetcher/tx_fetcher.go index 7b21feadd..24095bf3e 100644 --- a/eth/fetcher/tx_fetcher.go +++ b/eth/fetcher/tx_fetcher.go @@ -29,7 +29,7 @@ import ( "github.com/ledgerwatch/erigon/common/mclock" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" //"github.com/ledgerwatch/erigon/metrics" ) diff --git a/eth/filters/filter.go b/eth/filters/filter.go index e171a2fb5..cd3c382b9 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -26,8 +26,8 @@ import ( "github.com/ledgerwatch/erigon/core/bloombits" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" ) type Backend interface { diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go index 18a66299b..d0d65925f 100644 --- a/eth/filters/filter_system.go +++ b/eth/filters/filter_system.go @@ -29,8 +29,8 @@ import ( "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" ) // Type determines the kind of filter and is used to put the filter in to diff --git a/eth/gasprice/gasprice.go b/eth/gasprice/gasprice.go index e43de7bbf..e102297e9 100644 --- a/eth/gasprice/gasprice.go +++ b/eth/gasprice/gasprice.go @@ -26,9 +26,9 @@ import ( "github.com/holiman/uint256" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" ) const sampleNumber = 3 // Number of transactions sampled in a block diff --git a/eth/integrity/trie.go b/eth/integrity/trie.go index 721cfc400..0f308e048 100644 --- a/eth/integrity/trie.go +++ b/eth/integrity/trie.go @@ -12,8 +12,8 @@ import ( "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/turbo/trie" + "github.com/ledgerwatch/log/v3" ) // AssertSubset a & b == a - checks whether a is subset of b diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index 6121dd480..9d847dfdb 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -24,8 +24,8 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) // handleGetBlockHeaders handles Block header query, collect the requested headers and reply diff --git a/eth/stagedsync/chain_reader.go b/eth/stagedsync/chain_reader.go index 1260c1e86..17bf2f518 100644 --- a/eth/stagedsync/chain_reader.go +++ b/eth/stagedsync/chain_reader.go @@ -5,8 +5,8 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) // Implements consensus.ChainReader diff --git a/eth/stagedsync/stage_bodies.go b/eth/stagedsync/stage_bodies.go index e5eb0a9d5..c178a475a 100644 --- a/eth/stagedsync/stage_bodies.go +++ b/eth/stagedsync/stage_bodies.go @@ -11,12 +11,12 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/adapter" "github.com/ledgerwatch/erigon/turbo/stages/bodydownload" "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" + "github.com/ledgerwatch/log/v3" ) var stageBodiesGauge = metrics.NewRegisteredGauge("stage/bodies", nil) diff --git a/eth/stagedsync/stage_call_traces.go b/eth/stagedsync/stage_call_traces.go index cae0edd30..1bd07cbb0 100644 --- a/eth/stagedsync/stage_call_traces.go +++ b/eth/stagedsync/stage_call_traces.go @@ -22,8 +22,8 @@ import ( "github.com/ledgerwatch/erigon/ethdb/bitmapdb" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) type CallTracesCfg struct { diff --git a/eth/stagedsync/stage_execute.go b/eth/stagedsync/stage_execute.go index f09ccb633..88f5d513a 100644 --- a/eth/stagedsync/stage_execute.go +++ b/eth/stagedsync/stage_execute.go @@ -26,10 +26,10 @@ import ( "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/shards" + "github.com/ledgerwatch/log/v3" ) var stageExecutionGauge = metrics.NewRegisteredGauge("stage/execution", nil) diff --git a/eth/stagedsync/stage_finish.go b/eth/stagedsync/stage_finish.go index 5b5399c42..830567270 100644 --- a/eth/stagedsync/stage_finish.go +++ b/eth/stagedsync/stage_finish.go @@ -7,8 +7,8 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/turbo/snapshotsync" + "github.com/ledgerwatch/log/v3" ) type FinishCfg struct { diff --git a/eth/stagedsync/stage_hashstate.go b/eth/stagedsync/stage_hashstate.go index 68d9ec33a..9feb114c6 100644 --- a/eth/stagedsync/stage_hashstate.go +++ b/eth/stagedsync/stage_hashstate.go @@ -13,7 +13,7 @@ import ( "github.com/ledgerwatch/erigon/common/etl" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) type HashStateCfg struct { diff --git a/eth/stagedsync/stage_headers.go b/eth/stagedsync/stage_headers.go index b9fe1083e..5285be65d 100644 --- a/eth/stagedsync/stage_headers.go +++ b/eth/stagedsync/stage_headers.go @@ -15,11 +15,11 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" + "github.com/ledgerwatch/log/v3" ) var stageHeadersGauge = metrics.NewRegisteredGauge("stage/headers", nil) diff --git a/eth/stagedsync/stage_headers_snapshot.go b/eth/stagedsync/stage_headers_snapshot.go index dc9ea0396..fcc67a015 100644 --- a/eth/stagedsync/stage_headers_snapshot.go +++ b/eth/stagedsync/stage_headers_snapshot.go @@ -9,8 +9,8 @@ import ( "github.com/ledgerwatch/erigon/eth/ethconfig" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/turbo/snapshotsync" + "github.com/ledgerwatch/log/v3" ) type SnapshotHeadersCfg struct { diff --git a/eth/stagedsync/stage_indexes.go b/eth/stagedsync/stage_indexes.go index 38b43d65b..0707eaa9f 100644 --- a/eth/stagedsync/stage_indexes.go +++ b/eth/stagedsync/stage_indexes.go @@ -20,7 +20,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/bitmapdb" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) type HistoryCfg struct { diff --git a/eth/stagedsync/stage_interhashes.go b/eth/stagedsync/stage_interhashes.go index 3faffc9b8..0512504fe 100644 --- a/eth/stagedsync/stage_interhashes.go +++ b/eth/stagedsync/stage_interhashes.go @@ -16,8 +16,8 @@ import ( "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/turbo/trie" + "github.com/ledgerwatch/log/v3" ) type TrieCfg struct { diff --git a/eth/stagedsync/stage_log_index.go b/eth/stagedsync/stage_log_index.go index 207dd828f..185b970ae 100644 --- a/eth/stagedsync/stage_log_index.go +++ b/eth/stagedsync/stage_log_index.go @@ -19,7 +19,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/cbor" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/eth/stagedsync/stage_mining_create_block.go b/eth/stagedsync/stage_mining_create_block.go index 274ed1b12..89213a324 100644 --- a/eth/stagedsync/stage_mining_create_block.go +++ b/eth/stagedsync/stage_mining_create_block.go @@ -16,8 +16,8 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/ethutils" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) type MiningBlock struct { diff --git a/eth/stagedsync/stage_mining_exec.go b/eth/stagedsync/stage_mining_exec.go index 5da01c866..b33f7742d 100644 --- a/eth/stagedsync/stage_mining_exec.go +++ b/eth/stagedsync/stage_mining_exec.go @@ -14,8 +14,8 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) type MiningExecCfg struct { diff --git a/eth/stagedsync/stage_mining_finish.go b/eth/stagedsync/stage_mining_finish.go index dce953ff6..d7150bba0 100644 --- a/eth/stagedsync/stage_mining_finish.go +++ b/eth/stagedsync/stage_mining_finish.go @@ -6,8 +6,8 @@ import ( "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) type MiningFinishCfg struct { diff --git a/eth/stagedsync/stage_senders.go b/eth/stagedsync/stage_senders.go index 64a0a979c..31df20c91 100644 --- a/eth/stagedsync/stage_senders.go +++ b/eth/stagedsync/stage_senders.go @@ -17,8 +17,8 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/secp256k1" ) diff --git a/eth/stagedsync/stage_tevm.go b/eth/stagedsync/stage_tevm.go index 3ec7be07d..87245eb9e 100644 --- a/eth/stagedsync/stage_tevm.go +++ b/eth/stagedsync/stage_tevm.go @@ -16,9 +16,9 @@ import ( "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/olddb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) var stageTranspileGauge = metrics.NewRegisteredGauge("stage/tevm", nil) diff --git a/eth/stagedsync/stage_txpool.go b/eth/stagedsync/stage_txpool.go index b9219fd89..bc2abc028 100644 --- a/eth/stagedsync/stage_txpool.go +++ b/eth/stagedsync/stage_txpool.go @@ -11,7 +11,7 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) type TxPoolCfg struct { diff --git a/eth/stagedsync/sync.go b/eth/stagedsync/sync.go index 58392f9e2..f75d1c475 100644 --- a/eth/stagedsync/sync.go +++ b/eth/stagedsync/sync.go @@ -10,7 +10,7 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) type Sync struct { diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 27ade1acd..4e109413b 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -34,7 +34,7 @@ import ( "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm/stack" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js. diff --git a/ethdb/cbor/pool.go b/ethdb/cbor/pool.go index fa33ff114..8e483d5bb 100644 --- a/ethdb/cbor/pool.go +++ b/ethdb/cbor/pool.go @@ -4,7 +4,7 @@ import ( "fmt" "io" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/ugorji/go/codec" ) diff --git a/ethdb/mdbx/kv_abstract_test.go b/ethdb/mdbx/kv_abstract_test.go index d1dcaa40c..632a5e36d 100644 --- a/ethdb/mdbx/kv_abstract_test.go +++ b/ethdb/mdbx/kv_abstract_test.go @@ -13,7 +13,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/remotedb" "github.com/ledgerwatch/erigon/ethdb/remotedbserver" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc" diff --git a/ethdb/mdbx/kv_mdbx.go b/ethdb/mdbx/kv_mdbx.go index 1e94f7d87..bede1fc80 100644 --- a/ethdb/mdbx/kv_mdbx.go +++ b/ethdb/mdbx/kv_mdbx.go @@ -16,8 +16,8 @@ import ( "github.com/c2h5oh/datasize" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" + "github.com/ledgerwatch/log/v3" "github.com/torquem-ch/mdbx-go/mdbx" ) diff --git a/ethdb/mdbx/kv_migrator_test.go b/ethdb/mdbx/kv_migrator_test.go index 059638ce6..f7af31d45 100644 --- a/ethdb/mdbx/kv_migrator_test.go +++ b/ethdb/mdbx/kv_migrator_test.go @@ -8,7 +8,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/memdb" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/stretchr/testify/require" ) diff --git a/ethdb/mdbx/util.go b/ethdb/mdbx/util.go index 0c1c74425..9a10577d9 100644 --- a/ethdb/mdbx/util.go +++ b/ethdb/mdbx/util.go @@ -2,7 +2,7 @@ package mdbx import ( "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" mdbxbind "github.com/torquem-ch/mdbx-go/mdbx" ) diff --git a/ethdb/memdb/memory_database.go b/ethdb/memdb/memory_database.go index cf8082f25..5cdbdea39 100644 --- a/ethdb/memdb/memory_database.go +++ b/ethdb/memdb/memory_database.go @@ -22,7 +22,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) func New() kv.RwDB { diff --git a/ethdb/olddb/mutation.go b/ethdb/olddb/mutation.go index c6e9ea7cd..cfed4ec6d 100644 --- a/ethdb/olddb/mutation.go +++ b/ethdb/olddb/mutation.go @@ -14,7 +14,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) type mutation struct { diff --git a/ethdb/olddb/object_db.go b/ethdb/olddb/object_db.go index 4ed05fb00..d5e170e32 100644 --- a/ethdb/olddb/object_db.go +++ b/ethdb/olddb/object_db.go @@ -24,7 +24,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // ObjectDatabase - is an object-style interface of DB accessing diff --git a/ethdb/olddb/tx_db.go b/ethdb/olddb/tx_db.go index ad187b3d0..a5bf69e93 100644 --- a/ethdb/olddb/tx_db.go +++ b/ethdb/olddb/tx_db.go @@ -6,7 +6,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // TxDb - provides Database interface around ethdb.Tx diff --git a/ethdb/privateapi/all.go b/ethdb/privateapi/all.go index 35a2a90fc..13b60ab4b 100644 --- a/ethdb/privateapi/all.go +++ b/ethdb/privateapi/all.go @@ -11,8 +11,8 @@ import ( "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon/ethdb/remotedbserver" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/keepalive" diff --git a/ethdb/privateapi/ethbackend.go b/ethdb/privateapi/ethbackend.go index 47575a1fe..c49c4acf1 100644 --- a/ethdb/privateapi/ethbackend.go +++ b/ethdb/privateapi/ethbackend.go @@ -9,9 +9,9 @@ import ( types2 "github.com/ledgerwatch/erigon-lib/gointerfaces/types" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/ethdb/privateapi/mining.go b/ethdb/privateapi/mining.go index 7cc236a02..a0f348753 100644 --- a/ethdb/privateapi/mining.go +++ b/ethdb/privateapi/mining.go @@ -12,8 +12,8 @@ import ( "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/ethdb/privateapi/txpool.go b/ethdb/privateapi/txpool.go index 4c6209f53..85c49a35f 100644 --- a/ethdb/privateapi/txpool.go +++ b/ethdb/privateapi/txpool.go @@ -12,8 +12,8 @@ import ( "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" "google.golang.org/protobuf/types/known/emptypb" ) diff --git a/ethdb/remotedb/kv_remote.go b/ethdb/remotedb/kv_remote.go index 483a20e86..b17e59d6d 100644 --- a/ethdb/remotedb/kv_remote.go +++ b/ethdb/remotedb/kv_remote.go @@ -17,7 +17,7 @@ import ( "github.com/ledgerwatch/erigon-lib/gointerfaces/remote" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/grpc/backoff" "google.golang.org/grpc/credentials" diff --git a/ethdb/snapshotdb/kv_snapshot.go b/ethdb/snapshotdb/kv_snapshot.go index 93de1a433..5e8ee3a43 100644 --- a/ethdb/snapshotdb/kv_snapshot.go +++ b/ethdb/snapshotdb/kv_snapshot.go @@ -10,7 +10,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) var ( diff --git a/ethdb/snapshotdb/kv_snapshot_test.go b/ethdb/snapshotdb/kv_snapshot_test.go index ea2a1493b..28d652c19 100644 --- a/ethdb/snapshotdb/kv_snapshot_test.go +++ b/ethdb/snapshotdb/kv_snapshot_test.go @@ -13,7 +13,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" kv2 "github.com/ledgerwatch/erigon/ethdb/memdb" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/stretchr/testify/require" ) diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 98f39063d..b8c32fd8a 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -41,7 +41,7 @@ import ( "github.com/ledgerwatch/erigon/eth" "github.com/ledgerwatch/erigon/eth/downloader" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon/miner" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/p2p" diff --git a/go.mod b/go.mod index 970876d1b..974d1c439 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,6 @@ require ( github.com/fatih/color v1.7.0 github.com/fjl/gencodec v0.0.0-20191126094850-e283372f291f github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect - github.com/go-stack/stack v1.8.0 github.com/goccy/go-json v0.4.11 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/protobuf v1.5.2 @@ -40,10 +39,10 @@ require ( github.com/julienschmidt/httprouter v1.3.0 github.com/kevinburke/go-bindata v3.21.0+incompatible github.com/ledgerwatch/erigon-lib v0.0.0-20210709133046-4df3c6b79da0 + github.com/ledgerwatch/log/v3 v3.2.0 // indirect github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d github.com/logrusorgru/aurora v2.0.3+incompatible - github.com/mattn/go-colorable v0.1.7 - github.com/mattn/go-isatty v0.0.12 + github.com/mattn/go-colorable v0.1.8 github.com/pelletier/go-toml v1.9.3 github.com/petar/GoLLRB v0.0.0-20190514000832-33fb24c13b99 github.com/prometheus/client_golang v1.9.0 @@ -63,7 +62,7 @@ require ( go.uber.org/atomic v1.9.0 golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e golang.org/x/sync v0.0.0-20201207232520-09787c993a3a - golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 + golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 golang.org/x/tools v0.0.0-20210106214847-113979e3529a google.golang.org/grpc v1.39.0 diff --git a/go.sum b/go.sum index 4aefb6bd3..760475bea 100644 --- a/go.sum +++ b/go.sum @@ -633,6 +633,20 @@ github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7 github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/ledgerwatch/erigon-lib v0.0.0-20210709133046-4df3c6b79da0 h1:ccfmrKMAnxPE3p6z/h1qlvos8wjMrOcB95ThfR37RjQ= github.com/ledgerwatch/erigon-lib v0.0.0-20210709133046-4df3c6b79da0/go.mod h1:y8vIF0uAO6raqzgKZ5AILLXC+7gfr8nyRLbacmZrZ8Y= +github.com/ledgerwatch/log/v3 v3.0.0 h1:kz3UJBwYeLbJKm8zDa93KVwM3fN7lOFD31ndYtoM3aU= +github.com/ledgerwatch/log/v3 v3.0.0/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0= +github.com/ledgerwatch/log/v3 v3.1.0 h1:a+fO7LV1qCTqm+oQezCL/3SUM041i7LntGOCjgOPHBM= +github.com/ledgerwatch/log/v3 v3.1.0/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0= +github.com/ledgerwatch/log/v3 v3.1.1 h1:TaWe+xAMwjOeRKAPAIPm1xRnrr7u8DCKZB26K3I+RVc= +github.com/ledgerwatch/log/v3 v3.1.1/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0= +github.com/ledgerwatch/log/v3 v3.1.2 h1:V0DDOh2+axKRRf21Yz52VzfJXDUuJiLMzHMxA1bG+eo= +github.com/ledgerwatch/log/v3 v3.1.2/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0= +github.com/ledgerwatch/log/v3 v3.1.3-0.20210728073401-e21d8bb6d65e h1:fJ5g9p88f6UHyodWd26Nn5vfJn1H8/wVeBEdkjlAHxY= +github.com/ledgerwatch/log/v3 v3.1.3-0.20210728073401-e21d8bb6d65e/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0= +github.com/ledgerwatch/log/v3 v3.1.3-0.20210728073838-4d2d3f224d42 h1:NJjceRCXRKPma/Nil30r4x1JOJyCdqEaGIpR7xJHmt0= +github.com/ledgerwatch/log/v3 v3.1.3-0.20210728073838-4d2d3f224d42/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0= +github.com/ledgerwatch/log/v3 v3.2.0 h1:g0lVx5/hDQs+t+l7xzLTXDDlx+7W2JeTcoWQJQXhXJk= +github.com/ledgerwatch/log/v3 v3.2.0/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0= github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d h1:/IKMrJdfRsoYNc36PXqP4xMH3vhW/8IQyBKGQbKZUno= github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d/go.mod h1:SPmqJFciiF/Q0mPt2jVs2dTr/1TZBTIA+kPMmKgBAak= github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= @@ -668,6 +682,8 @@ github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -680,6 +696,8 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= +github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -1264,6 +1282,8 @@ golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/internal/debug/api.go b/internal/debug/api.go index 01e2f1237..25cda01c3 100644 --- a/internal/debug/api.go +++ b/internal/debug/api.go @@ -34,7 +34,7 @@ import ( "sync" "time" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // Handler is the global debugging handler. @@ -54,19 +54,21 @@ type HandlerT struct { // Verbosity sets the log verbosity ceiling. The verbosity of individual packages // and source files can be raised using Vmodule. func (*HandlerT) Verbosity(level int) { - glogger.Verbosity(log.Lvl(level)) + //glogger.Verbosity(log.Lvl(level)) } // Vmodule sets the log verbosity pattern. See package log for details on the // pattern syntax. func (*HandlerT) Vmodule(pattern string) error { - return glogger.Vmodule(pattern) + //return glogger.Vmodule(pattern) + return nil } // BacktraceAt sets the log backtrace location. See package log for details on // the pattern syntax. func (*HandlerT) BacktraceAt(location string) error { - return glogger.BacktraceAt(location) + //return glogger.BacktraceAt(location) + return nil } // MemStats returns detailed runtime memory statistics. diff --git a/internal/debug/flags.go b/internal/debug/flags.go index 7817df357..aa4a96f29 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -18,7 +18,6 @@ package debug import ( "fmt" - "io" "net/http" _ "net/http/pprof" "os" @@ -27,11 +26,9 @@ import ( "syscall" "time" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/metrics/exp" - "github.com/mattn/go-colorable" - "github.com/mattn/go-isatty" + "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" "github.com/urfave/cli" ) @@ -126,36 +123,40 @@ var DeprecatedFlags = []cli.Flag{ legacyBlockprofilerateFlag, legacyCpuprofileFlag, } -var glogger *log.GlogHandler +//var glogger *log.GlogHandler func init() { - glogger = log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) - glogger.Verbosity(log.LvlInfo) - log.Root().SetHandler(glogger) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) + //glogger = log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false))) + //glogger.Verbosity(log.LvlInfo) + //log.Root().SetHandler(glogger) } func SetupCobra(cmd *cobra.Command) error { flags := cmd.Flags() - dbg, err := flags.GetBool(debugFlag.Name) - if err != nil { - return err - } - lvl, err := flags.GetInt(verbosityFlag.Name) - if err != nil { - return err - } - vmodule, err := flags.GetString(vmoduleFlag.Name) - if err != nil { - return err - } - backtrace, err := flags.GetString(backtraceAtFlag.Name) - if err != nil { - return err - } + /* + dbg, err := flags.GetBool(debugFlag.Name) + if err != nil { + return err + } + lvl, err := flags.GetInt(verbosityFlag.Name) + if err != nil { + return err + } + vmodule, err := flags.GetString(vmoduleFlag.Name) + if err != nil { + return err + } + backtrace, err := flags.GetString(backtraceAtFlag.Name) + if err != nil { + return err + } - _, glogger = log.SetupDefaultTerminalLogger(log.Lvl(lvl), vmodule, backtrace) - log.PrintOrigins(dbg) + _, glogger = log.SetupDefaultTerminalLogger(log.Lvl(lvl), vmodule, backtrace) + log.PrintOrigins(dbg) + */ + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) memprofilerate, err := flags.GetInt(memprofilerateFlag.Name) if err != nil { @@ -236,25 +237,26 @@ func SetupCobra(cmd *cobra.Command) error { // Setup initializes profiling and logging based on the CLI flags. // It should be called as early as possible in the program. func Setup(ctx *cli.Context) error { - var ostream log.Handler - output := io.Writer(os.Stderr) + //var ostream log.Handler + //output := io.Writer(os.Stderr) if ctx.GlobalBool(logjsonFlag.Name) { - ostream = log.StreamHandler(output, log.JSONFormat()) + log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(ctx.GlobalInt(verbosityFlag.Name)), log.StreamHandler(os.Stderr, log.JsonFormat()))) + //ostream = log.StreamHandler(output, log.JsonFormat()) } else { - usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb" - if usecolor { - output = colorable.NewColorableStderr() - } - ostream = log.StreamHandler(output, log.TerminalFormat(usecolor)) + log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(ctx.GlobalInt(verbosityFlag.Name)), log.StderrHandler)) } - glogger.SetHandler(ostream) - // logging - log.PrintOrigins(ctx.GlobalBool(debugFlag.Name)) - _, glogger = log.SetupDefaultTerminalLogger( - log.Lvl(ctx.GlobalInt(verbosityFlag.Name)), - ctx.GlobalString(vmoduleFlag.Name), - ctx.GlobalString(backtraceAtFlag.Name), - ) + //log.Root().SetHandler(ostream) + + /* + glogger.SetHandler(ostream) + // logging + log.PrintOrigins(ctx.GlobalBool(debugFlag.Name)) + _, glogger = log.SetupDefaultTerminalLogger( + log.Lvl(ctx.GlobalInt(verbosityFlag.Name)), + ctx.GlobalString(vmoduleFlag.Name), + ctx.GlobalString(backtraceAtFlag.Name), + ) + */ // profiling, tracing if ctx.GlobalIsSet(legacyMemprofilerateFlag.Name) { diff --git a/internal/debug/trace.go b/internal/debug/trace.go index ca2eba243..35d791ec2 100644 --- a/internal/debug/trace.go +++ b/internal/debug/trace.go @@ -23,7 +23,7 @@ import ( "os" "runtime/trace" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // StartGoTrace turns on tracing, writing to the given file. diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 68f121942..16b9227ff 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -31,8 +31,8 @@ import ( "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" ) /* diff --git a/internal/testlog/testlog.go b/internal/testlog/testlog.go index 3bef479da..ca2032fc3 100644 --- a/internal/testlog/testlog.go +++ b/internal/testlog/testlog.go @@ -21,12 +21,12 @@ import ( "sync" "testing" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // Handler returns a log handler which logs to the unit test log of t. func Handler(t *testing.T, level log.Lvl) log.Handler { - return log.LvlFilterHandler(level, &handler{t, log.TerminalFormat(false)}) + return log.LvlFilterHandler(level, &handler{t, log.TerminalFormat()}) } type handler struct { @@ -66,7 +66,7 @@ func Logger(t *testing.T, level log.Lvl) log.Logger { t: t, l: log.New(), mu: new(sync.Mutex), - h: &bufHandler{fmt: log.TerminalFormat(false)}, + h: &bufHandler{fmt: log.TerminalFormat()}, } l.l.SetHandler(log.LvlFilterHandler(level, l.h)) return l diff --git a/log/CONTRIBUTORS b/log/CONTRIBUTORS deleted file mode 100644 index a0866713b..000000000 --- a/log/CONTRIBUTORS +++ /dev/null @@ -1,11 +0,0 @@ -Contributors to log15: - -- Aaron L -- Alan Shreve -- Chris Hines -- Ciaran Downey -- Dmitry Chestnykh -- Evan Shaw -- Péter Szilágyi -- Trevor Gattis -- Vincent Vanackere diff --git a/log/LICENSE b/log/LICENSE deleted file mode 100644 index 5f0d1fb6a..000000000 --- a/log/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2014 Alan Shreve - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/log/README.md b/log/README.md deleted file mode 100644 index 47426806d..000000000 --- a/log/README.md +++ /dev/null @@ -1,77 +0,0 @@ -![obligatory xkcd](https://imgs.xkcd.com/comics/standards.png) - -# log15 [![godoc reference](https://godoc.org/github.com/inconshreveable/log15?status.png)](https://godoc.org/github.com/inconshreveable/log15) [![Build Status](https://travis-ci.org/inconshreveable/log15.svg?branch=master)](https://travis-ci.org/inconshreveable/log15) - -Package log15 provides an opinionated, simple toolkit for best-practice logging in Go (golang) that is both human and machine readable. It is modeled after the Go standard library's [`io`](https://golang.org/pkg/io/) and [`net/http`](https://golang.org/pkg/net/http/) packages and is an alternative to the standard library's [`log`](https://golang.org/pkg/log/) package. - -## Features -- A simple, easy-to-understand API -- Promotes structured logging by encouraging use of key/value pairs -- Child loggers which inherit and add their own private context -- Lazy evaluation of expensive operations -- Simple Handler interface allowing for construction of flexible, custom logging configurations with a tiny API. -- Color terminal support -- Built-in support for logging to files, streams, syslog, and the network -- Support for forking records to multiple handlers, buffering records for output, failing over from failed handler writes, + more - -## Versioning -The API of the master branch of log15 should always be considered unstable. If you want to rely on a stable API, -you must vendor the library. - -## Importing - -```go -import log "github.com/inconshreveable/log15" -``` - -## Examples - -```go -// all loggers can have key/value context -srvlog := log.New("module", "app/server") - -// all log messages can have key/value context -srvlog.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate) - -// child loggers with inherited context -connlog := srvlog.New("raddr", c.RemoteAddr()) -connlog.Info("connection open") - -// lazy evaluation -connlog.Debug("ping remote", "latency", log.Lazy{pingRemote}) - -// flexible configuration -srvlog.SetHandler(log.MultiHandler( - log.StreamHandler(os.Stderr, log.LogfmtFormat()), - log.LvlFilterHandler( - log.LvlError, - log.Must.FileHandler("errors.json", log.JSONFormat())))) -``` - -Will result in output that looks like this: - -``` -WARN[06-17|21:58:10] abnormal conn rate module=app/server rate=0.500 low=0.100 high=0.800 -INFO[06-17|21:58:10] connection open module=app/server raddr=10.0.0.1 -``` - -## Breaking API Changes -The following commits broke API stability. This reference is intended to help you understand the consequences of updating to a newer version -of log15. - -- 57a084d014d4150152b19e4e531399a7145d1540 - Added a `Get()` method to the `Logger` interface to retrieve the current handler -- 93404652ee366648fa622b64d1e2b67d75a3094a - `Record` field `Call` changed to `stack.Call` with switch to `github.com/go-stack/stack` -- a5e7613673c73281f58e15a87d2cf0cf111e8152 - Restored `syslog.Priority` argument to the `SyslogXxx` handler constructors - -## FAQ - -### The varargs style is brittle and error prone! Can I have type safety please? -Yes. Use `log.Ctx`: - -```go -srvlog := log.New(log.Ctx{"module": "app/server"}) -srvlog.Warn("abnormal conn rate", log.Ctx{"rate": curRate, "low": lowRate, "high": highRate}) -``` - -## License -Apache diff --git a/log/README_ETHEREUM.md b/log/README_ETHEREUM.md deleted file mode 100644 index f6c42ccc0..000000000 --- a/log/README_ETHEREUM.md +++ /dev/null @@ -1,5 +0,0 @@ -This package is a fork of https://github.com/inconshreveable/log15, with some -minor modifications required by the go-ethereum codebase: - - * Support for log level `trace` - * Modified behavior to exit on `critical` failure diff --git a/log/doc.go b/log/doc.go deleted file mode 100644 index 993743c0f..000000000 --- a/log/doc.go +++ /dev/null @@ -1,333 +0,0 @@ -/* -Package log15 provides an opinionated, simple toolkit for best-practice logging that is -both human and machine readable. It is modeled after the standard library's io and net/http -packages. - -This package enforces you to only log key/value pairs. Keys must be strings. Values may be -any type that you like. The default output format is logfmt, but you may also choose to use -JSON instead if that suits you. Here's how you log: - - log.Info("page accessed", "path", r.URL.Path, "user_id", user.id) - -This will output a line that looks like: - - lvl=info t=2014-05-02T16:07:23-0700 msg="page accessed" path=/org/71/profile user_id=9 - -Getting Started - -To get started, you'll want to import the library: - - import log "github.com/inconshreveable/log15" - - -Now you're ready to start logging: - - func main() { - log.Info("Program starting", "args", os.Args()) - } - - -Convention - -Because recording a human-meaningful message is common and good practice, the first argument to every -logging method is the value to the *implicit* key 'msg'. - -Additionally, the level you choose for a message will be automatically added with the key 'lvl', and so -will the current timestamp with key 't'. - -You may supply any additional context as a set of key/value pairs to the logging function. log15 allows -you to favor terseness, ordering, and speed over safety. This is a reasonable tradeoff for -logging functions. You don't need to explicitly state keys/values, log15 understands that they alternate -in the variadic argument list: - - log.Warn("size out of bounds", "low", lowBound, "high", highBound, "val", val) - -If you really do favor your type-safety, you may choose to pass a log.Ctx instead: - - log.Warn("size out of bounds", log.Ctx{"low": lowBound, "high": highBound, "val": val}) - - -Context loggers - -Frequently, you want to add context to a logger so that you can track actions associated with it. An http -request is a good example. You can easily create new loggers that have context that is automatically included -with each log line: - - requestlogger := log.New("path", r.URL.Path) - - // later - requestlogger.Debug("db txn commit", "duration", txnTimer.Finish()) - -This will output a log line that includes the path context that is attached to the logger: - - lvl=dbug t=2014-05-02T16:07:23-0700 path=/repo/12/add_hook msg="db txn commit" duration=0.12 - - -Handlers - -The Handler interface defines where log lines are printed to and how they are formatted. Handler is a -single interface that is inspired by net/http's handler interface: - - type Handler interface { - Log(r *Record) error - } - - -Handlers can filter records, format them, or dispatch to multiple other Handlers. -This package implements a number of Handlers for common logging patterns that are -easily composed to create flexible, custom logging structures. - -Here's an example handler that prints logfmt output to Stdout: - - handler := log.StreamHandler(os.Stdout, log.LogfmtFormat()) - -Here's an example handler that defers to two other handlers. One handler only prints records -from the rpc package in logfmt to standard out. The other prints records at Error level -or above in JSON formatted output to the file /var/log/service.json - - handler := log.MultiHandler( - log.LvlFilterHandler(log.LvlError, log.Must.FileHandler("/var/log/service.json", log.JSONFormat())), - log.MatchFilterHandler("pkg", "app/rpc" log.StdoutHandler()) - ) - -Logging File Names and Line Numbers - -This package implements three Handlers that add debugging information to the -context, CallerFileHandler, CallerFuncHandler and CallerStackHandler. Here's -an example that adds the source file and line number of each logging call to -the context. - - h := log.CallerFileHandler(log.StdoutHandler) - log.Root().SetHandler(h) - ... - log.Error("open file", "err", err) - -This will output a line that looks like: - - lvl=eror t=2014-05-02T16:07:23-0700 msg="open file" err="file not found" caller=data.go:42 - -Here's an example that logs the call stack rather than just the call site. - - h := log.CallerStackHandler("%+v", log.StdoutHandler) - log.Root().SetHandler(h) - ... - log.Error("open file", "err", err) - -This will output a line that looks like: - - lvl=eror t=2014-05-02T16:07:23-0700 msg="open file" err="file not found" stack="[pkg/data.go:42 pkg/cmd/main.go]" - -The "%+v" format instructs the handler to include the path of the source file -relative to the compile time GOPATH. The github.com/go-stack/stack package -documents the full list of formatting verbs and modifiers available. - -Custom Handlers - -The Handler interface is so simple that it's also trivial to write your own. Let's create an -example handler which tries to write to one handler, but if that fails it falls back to -writing to another handler and includes the error that it encountered when trying to write -to the primary. This might be useful when trying to log over a network socket, but if that -fails you want to log those records to a file on disk. - - type BackupHandler struct { - Primary Handler - Secondary Handler - } - - func (h *BackupHandler) Log (r *Record) error { - err := h.Primary.Log(r) - if err != nil { - r.Ctx = append(ctx, "primary_err", err) - return h.Secondary.Log(r) - } - return nil - } - -This pattern is so useful that a generic version that handles an arbitrary number of Handlers -is included as part of this library called FailoverHandler. - -Logging Expensive Operations - -Sometimes, you want to log values that are extremely expensive to compute, but you don't want to pay -the price of computing them if you haven't turned up your logging level to a high level of detail. - -This package provides a simple type to annotate a logging operation that you want to be evaluated -lazily, just when it is about to be logged, so that it would not be evaluated if an upstream Handler -filters it out. Just wrap any function which takes no arguments with the log.Lazy type. For example: - - func factorRSAKey() (factors []int) { - // return the factors of a very large number - } - - log.Debug("factors", log.Lazy{factorRSAKey}) - -If this message is not logged for any reason (like logging at the Error level), then -factorRSAKey is never evaluated. - -Dynamic context values - -The same log.Lazy mechanism can be used to attach context to a logger which you want to be -evaluated when the message is logged, but not when the logger is created. For example, let's imagine -a game where you have Player objects: - - type Player struct { - name string - alive bool - log.Logger - } - -You always want to log a player's name and whether they're alive or dead, so when you create the player -object, you might do: - - p := &Player{name: name, alive: true} - p.Logger = log.New("name", p.name, "alive", p.alive) - -Only now, even after a player has died, the logger will still report they are alive because the logging -context is evaluated when the logger was created. By using the Lazy wrapper, we can defer the evaluation -of whether the player is alive or not to each log message, so that the log records will reflect the player's -current state no matter when the log message is written: - - p := &Player{name: name, alive: true} - isAlive := func() bool { return p.alive } - player.Logger = log.New("name", p.name, "alive", log.Lazy{isAlive}) - -Terminal Format - -If log15 detects that stdout is a terminal, it will configure the default -handler for it (which is log.StdoutHandler) to use TerminalFormat. This format -logs records nicely for your terminal, including color-coded output based -on log level. - -Error Handling - -Becasuse log15 allows you to step around the type system, there are a few ways you can specify -invalid arguments to the logging functions. You could, for example, wrap something that is not -a zero-argument function with log.Lazy or pass a context key that is not a string. Since logging libraries -are typically the mechanism by which errors are reported, it would be onerous for the logging functions -to return errors. Instead, log15 handles errors by making these guarantees to you: - -- Any log record containing an error will still be printed with the error explained to you as part of the log record. - -- Any log record containing an error will include the context key LOG15_ERROR, enabling you to easily -(and if you like, automatically) detect if any of your logging calls are passing bad values. - -Understanding this, you might wonder why the Handler interface can return an error value in its Log method. Handlers -are encouraged to return errors only if they fail to write their log records out to an external source like if the -syslog daemon is not responding. This allows the construction of useful handlers which cope with those failures -like the FailoverHandler. - -Library Use - -log15 is intended to be useful for library authors as a way to provide configurable logging to -users of their library. Best practice for use in a library is to always disable all output for your logger -by default and to provide a public Logger instance that consumers of your library can configure. Like so: - - package yourlib - - import "github.com/inconshreveable/log15" - - var Log = log.New() - - func init() { - Log.SetHandler(log.DiscardHandler()) - } - -Users of your library may then enable it if they like: - - import "github.com/inconshreveable/log15" - import "example.com/yourlib" - - func main() { - handler := // custom handler setup - yourlib.Log.SetHandler(handler) - } - -Best practices attaching logger context - -The ability to attach context to a logger is a powerful one. Where should you do it and why? -I favor embedding a Logger directly into any persistent object in my application and adding -unique, tracing context keys to it. For instance, imagine I am writing a web browser: - - type Tab struct { - url string - render *RenderingContext - // ... - - Logger - } - - func NewTab(url string) *Tab { - return &Tab { - // ... - url: url, - - Logger: log.New("url", url), - } - } - -When a new tab is created, I assign a logger to it with the url of -the tab as context so it can easily be traced through the logs. -Now, whenever we perform any operation with the tab, we'll log with its -embedded logger and it will include the tab title automatically: - - tab.Debug("moved position", "idx", tab.idx) - -There's only one problem. What if the tab url changes? We could -use log.Lazy to make sure the current url is always written, but that -would mean that we couldn't trace a tab's full lifetime through our -logs after the user navigate to a new URL. - -Instead, think about what values to attach to your loggers the -same way you think about what to use as a key in a SQL database schema. -If it's possible to use a natural key that is unique for the lifetime of the -object, do so. But otherwise, log15's ext package has a handy RandId -function to let you generate what you might call "surrogate keys" -They're just random hex identifiers to use for tracing. Back to our -Tab example, we would prefer to set up our Logger like so: - - import logext "github.com/inconshreveable/log15/ext" - - t := &Tab { - // ... - url: url, - } - - t.Logger = log.New("id", logext.RandId(8), "url", log.Lazy{t.getUrl}) - return t - -Now we'll have a unique traceable identifier even across loading new urls, but -we'll still be able to see the tab's current url in the log messages. - -Must - -For all Handler functions which can return an error, there is a version of that -function which will return no error but panics on failure. They are all available -on the Must object. For example: - - log.Must.FileHandler("/path", log.JSONFormat) - log.Must.NetHandler("tcp", ":1234", log.JSONFormat) - -Inspiration and Credit - -All of the following excellent projects inspired the design of this library: - -code.google.com/p/log4go - -github.com/op/go-logging - -github.com/technoweenie/grohl - -github.com/Sirupsen/logrus - -github.com/kr/logfmt - -github.com/spacemonkeygo/spacelog - -golang's stdlib, notably io and net/http - -The Name - -https://xkcd.com/927/ - -*/ -package log diff --git a/log/format.go b/log/format.go deleted file mode 100644 index 51036106f..000000000 --- a/log/format.go +++ /dev/null @@ -1,376 +0,0 @@ -package log - -import ( - "bytes" - "encoding/json" - "fmt" - "reflect" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" - "unicode/utf8" -) - -const ( - timeFormat = "2006-01-02T15:04:05-0700" - termTimeFormat = "01-02|15:04:05.000" - floatFormat = 'f' - termMsgJust = 40 - termCtxMaxPadding = 40 -) - -// locationTrims are trimmed for display to avoid unwieldy log lines. -var locationTrims = []string{ - "github.com/ledgerwatch/erigon/", -} - -// PrintOrigins sets or unsets log location (file:line) printing for terminal -// format output. -func PrintOrigins(print bool) { - if print { - atomic.StoreUint32(&locationEnabled, 1) - } else { - atomic.StoreUint32(&locationEnabled, 0) - } -} - -// locationEnabled is an atomic flag controlling whether the terminal formatter -// should append the log locations too when printing entries. -var locationEnabled uint32 - -// locationLength is the maxmimum path length encountered, which all logs are -// padded to to aid in alignment. -var locationLength uint32 - -// fieldPadding is a global map with maximum field value lengths seen until now -// to allow padding log contexts in a bit smarter way. -var fieldPadding = make(map[string]int) - -// fieldPaddingLock is a global mutex protecting the field padding map. -var fieldPaddingLock sync.RWMutex - -type Format interface { - Format(r *Record) []byte -} - -// FormatFunc returns a new Format object which uses -// the given function to perform record formatting. -func FormatFunc(f func(*Record) []byte) Format { - return formatFunc(f) -} - -type formatFunc func(*Record) []byte - -func (f formatFunc) Format(r *Record) []byte { - return f(r) -} - -// TerminalStringer is an analogous interface to the stdlib stringer, allowing -// own types to have custom shortened serialization formats when printed to the -// screen. -type TerminalStringer interface { - TerminalString() string -} - -// TerminalFormat formats log records optimized for human readability on -// a terminal with color-coded level output and terser human friendly timestamp. -// This format should only be used for interactive programs or while developing. -// -// [LEVEL] [TIME] MESSAGE key=value key=value ... -// -// Example: -// -// [DBUG] [May 16 20:58:45] remove route ns=haproxy addr=127.0.0.1:50002 -// -func TerminalFormat(usecolor bool) Format { - return FormatFunc(func(r *Record) []byte { - var color = 0 - if usecolor { - switch r.Lvl { - case LvlCrit: - color = 35 - case LvlError: - color = 31 - case LvlWarn: - color = 33 - case LvlInfo: - color = 32 - case LvlDebug: - color = 36 - case LvlTrace: - color = 34 - } - } - - b := &bytes.Buffer{} - lvl := r.Lvl.AlignedString() - if atomic.LoadUint32(&locationEnabled) != 0 { - // Log origin printing was requested, format the location path and line number - location := fmt.Sprintf("%+v", r.Call) - for _, prefix := range locationTrims { - location = strings.TrimPrefix(location, prefix) - } - // Maintain the maximum location length for fancyer alignment - align := int(atomic.LoadUint32(&locationLength)) - if align < len(location) { - align = len(location) - atomic.StoreUint32(&locationLength, uint32(align)) - } - padding := strings.Repeat(" ", align-len(location)) - - // Assemble and print the log heading - if color > 0 { - fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s|%s]%s %s ", color, lvl, r.Time.Format(termTimeFormat), location, padding, r.Msg) - } else { - fmt.Fprintf(b, "%s[%s|%s]%s %s ", lvl, r.Time.Format(termTimeFormat), location, padding, r.Msg) - } - } else { - if color > 0 { - fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %s ", color, lvl, r.Time.Format(termTimeFormat), r.Msg) - } else { - fmt.Fprintf(b, "%s[%s] %s ", lvl, r.Time.Format(termTimeFormat), r.Msg) - } - } - // try to justify the log output for short messages - length := utf8.RuneCountInString(r.Msg) - if len(r.Ctx) > 0 && length < termMsgJust { - b.Write(bytes.Repeat([]byte{' '}, termMsgJust-length)) - } - // print the keys logfmt style - logfmt(b, r.Ctx, color, true) - return b.Bytes() - }) -} - -// LogfmtFormat prints records in logfmt format, an easy machine-parseable but human-readable -// format for key/value pairs. -// -// For more details see: http://godoc.org/github.com/kr/logfmt -// -func LogfmtFormat() Format { - return FormatFunc(func(r *Record) []byte { - common := []interface{}{r.KeyNames.Time, r.Time, r.KeyNames.Lvl, r.Lvl, r.KeyNames.Msg, r.Msg} - buf := &bytes.Buffer{} - logfmt(buf, append(common, r.Ctx...), 0, false) - return buf.Bytes() - }) -} - -func logfmt(buf *bytes.Buffer, ctx []interface{}, color int, term bool) { - for i := 0; i < len(ctx); i += 2 { - if i != 0 { - buf.WriteByte(' ') - } - - k, ok := ctx[i].(string) - v := formatLogfmtValue(ctx[i+1], term) - if !ok { - k, v = errorKey, formatLogfmtValue(k, term) - } - - // XXX: we should probably check that all of your key bytes aren't invalid - fieldPaddingLock.RLock() - padding := fieldPadding[k] - fieldPaddingLock.RUnlock() - - length := utf8.RuneCountInString(v) - if padding < length && length <= termCtxMaxPadding { - padding = length - - fieldPaddingLock.Lock() - fieldPadding[k] = padding - fieldPaddingLock.Unlock() - } - if color > 0 { - fmt.Fprintf(buf, "\x1b[%dm%s\x1b[0m=", color, k) - } else { - buf.WriteString(k) - buf.WriteByte('=') - } - buf.WriteString(v) - if i < len(ctx)-2 && padding > length { - buf.Write(bytes.Repeat([]byte{' '}, padding-length)) - } - } - buf.WriteByte('\n') -} - -// JSONFormat formats log records as JSON objects separated by newlines. -// It is the equivalent of JSONFormatEx(false, true). -func JSONFormat() Format { - return JSONFormatEx(false, true) -} - -// JSONFormatOrderedEx formats log records as JSON arrays. If pretty is true, -// records will be pretty-printed. If lineSeparated is true, records -// will be logged with a new line between each record. -func JSONFormatOrderedEx(pretty, lineSeparated bool) Format { - jsonMarshal := json.Marshal - if pretty { - jsonMarshal = func(v interface{}) ([]byte, error) { - return json.MarshalIndent(v, "", " ") - } - } - return FormatFunc(func(r *Record) []byte { - props := make(map[string]interface{}) - - props[r.KeyNames.Time] = r.Time - props[r.KeyNames.Lvl] = r.Lvl.String() - props[r.KeyNames.Msg] = r.Msg - - ctx := make([]string, len(r.Ctx)) - for i := 0; i < len(r.Ctx); i += 2 { - k, ok := r.Ctx[i].(string) - if !ok { - props[errorKey] = fmt.Sprintf("%+v is not a string key,", r.Ctx[i]) - } - ctx[i] = k - ctx[i+1] = formatLogfmtValue(r.Ctx[i+1], true) - } - props[r.KeyNames.Ctx] = ctx - - b, err := jsonMarshal(props) - if err != nil { - b, _ = jsonMarshal(map[string]string{ - errorKey: err.Error(), - }) - return b - } - if lineSeparated { - b = append(b, '\n') - } - return b - }) -} - -// JSONFormatEx formats log records as JSON objects. If pretty is true, -// records will be pretty-printed. If lineSeparated is true, records -// will be logged with a new line between each record. -func JSONFormatEx(pretty, lineSeparated bool) Format { - jsonMarshal := json.Marshal - if pretty { - jsonMarshal = func(v interface{}) ([]byte, error) { - return json.MarshalIndent(v, "", " ") - } - } - - return FormatFunc(func(r *Record) []byte { - props := make(map[string]interface{}) - - props[r.KeyNames.Time] = r.Time - props[r.KeyNames.Lvl] = r.Lvl.String() - props[r.KeyNames.Msg] = r.Msg - - for i := 0; i < len(r.Ctx); i += 2 { - k, ok := r.Ctx[i].(string) - if !ok { - props[errorKey] = fmt.Sprintf("%+v is not a string key", r.Ctx[i]) - } - props[k] = formatJSONValue(r.Ctx[i+1]) - } - - b, err := jsonMarshal(props) - if err != nil { - b, _ = jsonMarshal(map[string]string{ - errorKey: err.Error(), - }) - return b - } - - if lineSeparated { - b = append(b, '\n') - } - - return b - }) -} - -func formatShared(value interface{}) (result interface{}) { - defer func() { - if err := recover(); err != nil { - if v := reflect.ValueOf(value); v.Kind() == reflect.Ptr && v.IsNil() { - result = "nil" - } else { - panic(err) - } - } - }() - - switch v := value.(type) { - case time.Time: - return v.Format(timeFormat) - - case error: - return v.Error() - - case fmt.Stringer: - return v.String() - - default: - return v - } -} - -func formatJSONValue(value interface{}) interface{} { - value = formatShared(value) - switch value.(type) { - case int, int8, int16, int32, int64, float32, float64, uint, uint8, uint16, uint32, uint64, string: - return value - default: - return fmt.Sprintf("%+v", value) - } -} - -// formatValue formats a value for serialization -func formatLogfmtValue(value interface{}, term bool) string { - if value == nil { - return "nil" - } - - if t, ok := value.(time.Time); ok { - // Performance optimization: No need for escaping since the provided - // timeFormat doesn't have any escape characters, and escaping is - // expensive. - return t.Format(timeFormat) - } - if term { - if s, ok := value.(TerminalStringer); ok { - // Custom terminal stringer provided, use that - return escapeString(s.TerminalString()) - } - } - value = formatShared(value) - switch v := value.(type) { - case bool: - return strconv.FormatBool(v) - case float32: - return strconv.FormatFloat(float64(v), floatFormat, 3, 64) - case float64: - return strconv.FormatFloat(v, floatFormat, 3, 64) - case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64: - return fmt.Sprintf("%d", value) - case string: - return escapeString(v) - default: - return escapeString(fmt.Sprintf("%+v", value)) - } -} - -// escapeString checks if the provided string needs escaping/quoting, and -// calls strconv.Quote if needed -func escapeString(s string) string { - needsQuoting := false - for _, r := range s { - // We quote everything below " (0x34) and above~ (0x7E), plus equal-sign - if r <= '"' || r > '~' || r == '=' { - needsQuoting = true - break - } - } - if !needsQuoting { - return s - } - return strconv.Quote(s) -} diff --git a/log/handler.go b/log/handler.go deleted file mode 100644 index 792939c28..000000000 --- a/log/handler.go +++ /dev/null @@ -1,404 +0,0 @@ -package log - -import ( - "fmt" - "io" - "net" - "os" - "reflect" - "sync" - - "github.com/mattn/go-colorable" - "github.com/mattn/go-isatty" - - "github.com/go-stack/stack" -) - -// Handler defines where and how log records are written. -// A Logger prints its log records by writing to a Handler. -// Handlers are composable, providing you great flexibility in combining -// them to achieve the logging structure that suits your applications. -type Handler interface { - Log(r *Record) error -} - -// FuncHandler returns a Handler that logs records with the given -// function. -func FuncHandler(fn func(r *Record) error) Handler { - return funcHandler(fn) -} - -type funcHandler func(r *Record) error - -func (h funcHandler) Log(r *Record) error { - return h(r) -} - -// StreamHandler writes log records to an io.Writer -// with the given format. StreamHandler can be used -// to easily begin writing log records to other -// outputs. -// -// StreamHandler wraps itself with LazyHandler and SyncHandler -// to evaluate Lazy objects and perform safe concurrent writes. -func StreamHandler(wr io.Writer, fmtr Format) Handler { - h := FuncHandler(func(r *Record) error { - _, err := wr.Write(fmtr.Format(r)) - return err - }) - return LazyHandler(SyncHandler(h)) -} - -// SyncHandler can be wrapped around a handler to guarantee that -// only a single Log operation can proceed at a time. It's necessary -// for thread-safe concurrent writes. -func SyncHandler(h Handler) Handler { - var mu sync.Mutex - return FuncHandler(func(r *Record) error { - defer mu.Unlock() - mu.Lock() - return h.Log(r) - }) -} - -// FileHandler returns a handler which writes log records to the give file -// using the given format. If the path -// already exists, FileHandler will append to the given file. If it does not, -// FileHandler will create the file with mode 0644. -func FileHandler(path string, fmtr Format) (Handler, error) { - f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) - if err != nil { - return nil, err - } - return closingHandler{f, StreamHandler(f, fmtr)}, nil -} - -// NetHandler opens a socket to the given address and writes records -// over the connection. -func NetHandler(network, addr string, fmtr Format) (Handler, error) { - conn, err := net.Dial(network, addr) - if err != nil { - return nil, err - } - - return closingHandler{conn, StreamHandler(conn, fmtr)}, nil -} - -// XXX: closingHandler is essentially unused at the moment -// it's meant for a future time when the Handler interface supports -// a possible Close() operation -type closingHandler struct { - io.WriteCloser - Handler -} - -func (h *closingHandler) Close() error { - return h.WriteCloser.Close() -} - -// CallerFileHandler returns a Handler that adds the line number and file of -// the calling function to the context with key "caller". -func CallerFileHandler(h Handler) Handler { - return FuncHandler(func(r *Record) error { - r.Ctx = append(r.Ctx, "caller", fmt.Sprint(r.Call)) - return h.Log(r) - }) -} - -// CallerFuncHandler returns a Handler that adds the calling function name to -// the context with key "fn". -func CallerFuncHandler(h Handler) Handler { - return FuncHandler(func(r *Record) error { - r.Ctx = append(r.Ctx, "fn", formatCall("%+n", r.Call)) - return h.Log(r) - }) -} - -// This function is here to please go vet on Go < 1.8. -func formatCall(format string, c stack.Call) string { - return fmt.Sprintf(format, c) -} - -// CallerStackHandler returns a Handler that adds a stack trace to the context -// with key "stack". The stack trace is formatted as a space separated list of -// call sites inside matching []'s. The most recent call site is listed first. -// Each call site is formatted according to format. See the documentation of -// package github.com/go-stack/stack for the list of supported formats. -func CallerStackHandler(format string, h Handler) Handler { - return FuncHandler(func(r *Record) error { - s := stack.Trace().TrimBelow(r.Call).TrimRuntime() - if len(s) > 0 { - r.Ctx = append(r.Ctx, "stack", fmt.Sprintf(format, s)) - } - return h.Log(r) - }) -} - -// FilterHandler returns a Handler that only writes records to the -// wrapped Handler if the given function evaluates true. For example, -// to only log records where the 'err' key is not nil: -// -// logger.SetHandler(FilterHandler(func(r *Record) bool { -// for i := 0; i < len(r.Ctx); i += 2 { -// if r.Ctx[i] == "err" { -// return r.Ctx[i+1] != nil -// } -// } -// return false -// }, h)) -// -func FilterHandler(fn func(r *Record) bool, h Handler) Handler { - return FuncHandler(func(r *Record) error { - if fn(r) { - return h.Log(r) - } - return nil - }) -} - -// MatchFilterHandler returns a Handler that only writes records -// to the wrapped Handler if the given key in the logged -// context matches the value. For example, to only log records -// from your ui package: -// -// log.MatchFilterHandler("pkg", "app/ui", log.StdoutHandler) -// -func MatchFilterHandler(key string, value interface{}, h Handler) Handler { - return FilterHandler(func(r *Record) (pass bool) { - switch key { - case r.KeyNames.Lvl: - return r.Lvl == value - case r.KeyNames.Time: - return r.Time == value - case r.KeyNames.Msg: - return r.Msg == value - } - - for i := 0; i < len(r.Ctx); i += 2 { - if r.Ctx[i] == key { - return r.Ctx[i+1] == value - } - } - return false - }, h) -} - -// LvlFilterHandler returns a Handler that only writes -// records which are less than the given verbosity -// level to the wrapped Handler. For example, to only -// log Error/Crit records: -// -// log.LvlFilterHandler(log.LvlError, log.StdoutHandler) -// -func LvlFilterHandler(maxLvl Lvl, h Handler) Handler { - return FilterHandler(func(r *Record) (pass bool) { - return r.Lvl <= maxLvl - }, h) -} - -// MultiHandler dispatches any write to each of its handlers. -// This is useful for writing different types of log information -// to different locations. For example, to log to a file and -// standard error: -// -// log.MultiHandler( -// log.Must.FileHandler("/var/log/app.log", log.LogfmtFormat()), -// log.StderrHandler) -// -func MultiHandler(hs ...Handler) Handler { - return FuncHandler(func(r *Record) error { - for _, h := range hs { - // what to do about failures? - h.Log(r) - } - return nil - }) -} - -// FailoverHandler writes all log records to the first handler -// specified, but will failover and write to the second handler if -// the first handler has failed, and so on for all handlers specified. -// For example you might want to log to a network socket, but failover -// to writing to a file if the network fails, and then to -// standard out if the file write fails: -// -// log.FailoverHandler( -// log.Must.NetHandler("tcp", ":9090", log.JSONFormat()), -// log.Must.FileHandler("/var/log/app.log", log.LogfmtFormat()), -// log.StdoutHandler) -// -// All writes that do not go to the first handler will add context with keys of -// the form "failover_err_{idx}" which explain the error encountered while -// trying to write to the handlers before them in the list. -func FailoverHandler(hs ...Handler) Handler { - return FuncHandler(func(r *Record) error { - var err error - for i, h := range hs { - err = h.Log(r) - if err == nil { - return nil - } - r.Ctx = append(r.Ctx, fmt.Sprintf("failover_err_%d", i), err) - } - - return err - }) -} - -// ChannelHandler writes all records to the given channel. -// It blocks if the channel is full. Useful for async processing -// of log messages, it's used by BufferedHandler. -func ChannelHandler(recs chan<- *Record) Handler { - return FuncHandler(func(r *Record) error { - recs <- r - return nil - }) -} - -// BufferedHandler writes all records to a buffered -// channel of the given size which flushes into the wrapped -// handler whenever it is available for writing. Since these -// writes happen asynchronously, all writes to a BufferedHandler -// never return an error and any errors from the wrapped handler are ignored. -func BufferedHandler(bufSize int, h Handler) Handler { - recs := make(chan *Record, bufSize) - go func() { - for m := range recs { - _ = h.Log(m) - } - }() - return ChannelHandler(recs) -} - -// LazyHandler writes all values to the wrapped handler after evaluating -// any lazy functions in the record's context. It is already wrapped -// around StreamHandler and SyslogHandler in this library, you'll only need -// it if you write your own Handler. -func LazyHandler(h Handler) Handler { - return FuncHandler(func(r *Record) error { - // go through the values (odd indices) and reassign - // the values of any lazy fn to the result of its execution - hadErr := false - for i := 1; i < len(r.Ctx); i += 2 { - lz, ok := r.Ctx[i].(Lazy) - if ok { - v, err := evaluateLazy(lz) - if err != nil { - hadErr = true - r.Ctx[i] = err - } else { - if cs, ok := v.(stack.CallStack); ok { - v = cs.TrimBelow(r.Call).TrimRuntime() - } - r.Ctx[i] = v - } - } - } - - if hadErr { - r.Ctx = append(r.Ctx, errorKey, "bad lazy") - } - - return h.Log(r) - }) -} - -func evaluateLazy(lz Lazy) (interface{}, error) { - t := reflect.TypeOf(lz.Fn) - - if t.Kind() != reflect.Func { - return nil, fmt.Errorf("INVALID_LAZY, not func: %+v", lz.Fn) - } - - if t.NumIn() > 0 { - return nil, fmt.Errorf("INVALID_LAZY, func takes args: %+v", lz.Fn) - } - - if t.NumOut() == 0 { - return nil, fmt.Errorf("INVALID_LAZY, no func return val: %+v", lz.Fn) - } - - value := reflect.ValueOf(lz.Fn) - results := value.Call([]reflect.Value{}) - if len(results) == 1 { - return results[0].Interface(), nil - } - values := make([]interface{}, len(results)) - for i, v := range results { - values[i] = v.Interface() - } - return values, nil -} - -// DiscardHandler reports success for all writes but does nothing. -// It is useful for dynamically disabling logging at runtime via -// a Logger's SetHandler method. -func DiscardHandler() Handler { - return FuncHandler(func(r *Record) error { - return nil - }) -} - -// Must provides the following Handler creation functions -// which instead of returning an error parameter only return a Handler -// and panic on failure: FileHandler, NetHandler, SyslogHandler, SyslogNetHandler -var Must muster - -func must(h Handler, err error) Handler { - if err != nil { - panic(err) - } - return h -} - -type muster struct{} - -func (m muster) FileHandler(path string, fmtr Format) Handler { - return must(FileHandler(path, fmtr)) -} - -func (m muster) NetHandler(network, addr string, fmtr Format) Handler { - return must(NetHandler(network, addr, fmtr)) -} - -// verbosityPerModule sets the glog verbosity pattern. -// -// The syntax of the argument is a comma-separated list of pattern=N, where the -// pattern is a literal file name or "glob" pattern matching and N is a V level: -// pattern="gopher.go=3" -// sets the V level to 3 in all Go files named "gopher.go" -// -// pattern="foo=3" -// sets V to 3 in all files of any packages whose import path ends in "foo" -// -// pattern="foo/*=3" -// sets V to 3 in all files of any packages whose import path contains "foo" -// -// -// -// backtraceAt sets the glog backtrace location. When set to a file and line -// number holding a logging statement, a stack trace will be written to the Info -// log whenever execution hits that statement. -// Unlike verbosityPerModule, the ".go" must be present. -// -func SetupDefaultTerminalLogger(lvl Lvl, verbosityPerModule string, backtraceAt string) (ostream Handler, glogger *GlogHandler) { - usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb" - output := io.Writer(os.Stderr) - if usecolor { - output = colorable.NewColorableStderr() - } - ostream = StreamHandler(output, TerminalFormat(usecolor)) - glogger = NewGlogHandler(ostream) - Root().SetHandler(glogger) - glogger.Verbosity(lvl) - if err := glogger.Vmodule(verbosityPerModule); err != nil { - panic(err) - } - if backtraceAt != "" { - if err := glogger.BacktraceAt(backtraceAt); err != nil { - panic(err) - } - } - - return ostream, glogger -} diff --git a/log/handler_glog.go b/log/handler_glog.go deleted file mode 100644 index 9b1d4efaf..000000000 --- a/log/handler_glog.go +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package log - -import ( - "errors" - "fmt" - "regexp" - "runtime" - "strconv" - "strings" - "sync" - "sync/atomic" -) - -// errVmoduleSyntax is returned when a user vmodule pattern is invalid. -var errVmoduleSyntax = errors.New("expect comma-separated list of filename=N") - -// errTraceSyntax is returned when a user backtrace pattern is invalid. -var errTraceSyntax = errors.New("expect file.go:234") - -// GlogHandler is a log handler that mimics the filtering features of Google's -// glog logger: setting global log levels; overriding with callsite pattern -// matches; and requesting backtraces at certain positions. -type GlogHandler struct { - origin Handler // The origin handler this wraps - - level uint32 // Current log level, atomically accessible - override uint32 // Flag whether overrides are used, atomically accessible - backtrace uint32 // Flag whether backtrace location is set - - patterns []pattern // Current list of patterns to override with - siteCache map[uintptr]Lvl // Cache of callsite pattern evaluations - location string // file:line location where to do a stackdump at - lock sync.RWMutex // Lock protecting the override pattern list -} - -// NewGlogHandler creates a new log handler with filtering functionality similar -// to Google's glog logger. The returned handler implements Handler. -func NewGlogHandler(h Handler) *GlogHandler { - return &GlogHandler{ - origin: h, - } -} - -// SetHandler updates the handler to write records to the specified sub-handler. -func (h *GlogHandler) SetHandler(nh Handler) { - h.origin = nh -} - -// pattern contains a filter for the Vmodule option, holding a verbosity level -// and a file pattern to match. -type pattern struct { - pattern *regexp.Regexp - level Lvl -} - -// Verbosity sets the glog verbosity ceiling. The verbosity of individual packages -// and source files can be raised using Vmodule. -func (h *GlogHandler) Verbosity(level Lvl) { - atomic.StoreUint32(&h.level, uint32(level)) -} - -// Vmodule sets the glog verbosity pattern. -// -// The syntax of the argument is a comma-separated list of pattern=N, where the -// pattern is a literal file name or "glob" pattern matching and N is a V level. -// -// For instance: -// -// pattern="gopher.go=3" -// sets the V level to 3 in all Go files named "gopher.go" -// -// pattern="foo=3" -// sets V to 3 in all files of any packages whose import path ends in "foo" -// -// pattern="foo/*=3" -// sets V to 3 in all files of any packages whose import path contains "foo" -func (h *GlogHandler) Vmodule(ruleset string) error { - var filter []pattern - for _, rule := range strings.Split(ruleset, ",") { - // Empty strings such as from a trailing comma can be ignored - if len(rule) == 0 { - continue - } - // Ensure we have a pattern = level filter rule - parts := strings.Split(rule, "=") - if len(parts) != 2 { - return errVmoduleSyntax - } - parts[0] = strings.TrimSpace(parts[0]) - parts[1] = strings.TrimSpace(parts[1]) - if len(parts[0]) == 0 || len(parts[1]) == 0 { - return errVmoduleSyntax - } - // Parse the level and if correct, assemble the filter rule - level, err := strconv.Atoi(parts[1]) - if err != nil { - return errVmoduleSyntax - } - if level <= 0 { - continue // Ignore. It's harmless but no point in paying the overhead. - } - // Compile the rule pattern into a regular expression - matcher := ".*" - for _, comp := range strings.Split(parts[0], "/") { - if comp == "*" { - matcher += "(/.*)?" - } else if comp != "" { - matcher += "/" + regexp.QuoteMeta(comp) - } - } - if !strings.HasSuffix(parts[0], ".go") { - matcher += "/[^/]+\\.go" - } - matcher = matcher + "$" - - re, _ := regexp.Compile(matcher) - filter = append(filter, pattern{re, Lvl(level)}) - } - // Swap out the vmodule pattern for the new filter system - h.lock.Lock() - defer h.lock.Unlock() - - h.patterns = filter - h.siteCache = make(map[uintptr]Lvl) - atomic.StoreUint32(&h.override, uint32(len(filter))) - - return nil -} - -// BacktraceAt sets the glog backtrace location. When set to a file and line -// number holding a logging statement, a stack trace will be written to the Info -// log whenever execution hits that statement. -// -// Unlike with Vmodule, the ".go" must be present. -func (h *GlogHandler) BacktraceAt(location string) error { - // Ensure the backtrace location contains two non-empty elements - parts := strings.Split(location, ":") - if len(parts) != 2 { - return errTraceSyntax - } - parts[0] = strings.TrimSpace(parts[0]) - parts[1] = strings.TrimSpace(parts[1]) - if len(parts[0]) == 0 || len(parts[1]) == 0 { - return errTraceSyntax - } - // Ensure the .go prefix is present and the line is valid - if !strings.HasSuffix(parts[0], ".go") { - return errTraceSyntax - } - if _, err := strconv.Atoi(parts[1]); err != nil { - return errTraceSyntax - } - // All seems valid - h.lock.Lock() - defer h.lock.Unlock() - - h.location = location - atomic.StoreUint32(&h.backtrace, uint32(len(location))) - - return nil -} - -// Log implements Handler.Log, filtering a log record through the global, local -// and backtrace filters, finally emitting it if either allow it through. -func (h *GlogHandler) Log(r *Record) error { - // If backtracing is requested, check whether this is the callsite - if atomic.LoadUint32(&h.backtrace) > 0 { - // Everything below here is slow. Although we could cache the call sites the - // same way as for vmodule, backtracing is so rare it's not worth the extra - // complexity. - h.lock.RLock() - match := h.location == r.Call.String() - h.lock.RUnlock() - - if match { - // Callsite matched, raise the log level to info and gather the stacks - r.Lvl = LvlInfo - - buf := make([]byte, 1024*1024) - buf = buf[:runtime.Stack(buf, true)] - r.Msg += "\n\n" + string(buf) - } - } - // If the global log level allows, fast track logging - if atomic.LoadUint32(&h.level) >= uint32(r.Lvl) { - return h.origin.Log(r) - } - // If no local overrides are present, fast track skipping - if atomic.LoadUint32(&h.override) == 0 { - return nil - } - // Check callsite cache for previously calculated log levels - h.lock.RLock() - lvl, ok := h.siteCache[r.Call.Frame().PC] - h.lock.RUnlock() - - // If we didn't cache the callsite yet, calculate it - if !ok { - h.lock.Lock() - for _, rule := range h.patterns { - if rule.pattern.MatchString(fmt.Sprintf("%+s", r.Call)) { - h.siteCache[r.Call.Frame().PC], lvl, ok = rule.level, rule.level, true - break - } - } - // If no rule matched, remember to drop log the next time - if !ok { - h.siteCache[r.Call.Frame().PC] = 0 - } - h.lock.Unlock() - } - if lvl >= r.Lvl { - return h.origin.Log(r) - } - return nil -} diff --git a/log/handler_go13.go b/log/handler_go13.go deleted file mode 100644 index 0843ed0e5..000000000 --- a/log/handler_go13.go +++ /dev/null @@ -1,26 +0,0 @@ -// +build !go1.4 - -package log - -import ( - "sync/atomic" - "unsafe" -) - -// swapHandler wraps another handler that may be swapped out -// dynamically at runtime in a thread-safe fashion. -type swapHandler struct { - handler unsafe.Pointer -} - -func (h *swapHandler) Log(r *Record) error { - return h.Get().Log(r) -} - -func (h *swapHandler) Get() Handler { - return *(*Handler)(atomic.LoadPointer(&h.handler)) -} - -func (h *swapHandler) Swap(newHandler Handler) { - atomic.StorePointer(&h.handler, unsafe.Pointer(&newHandler)) -} diff --git a/log/handler_go14.go b/log/handler_go14.go deleted file mode 100644 index 05dedbf2a..000000000 --- a/log/handler_go14.go +++ /dev/null @@ -1,23 +0,0 @@ -// +build go1.4 - -package log - -import "sync/atomic" - -// swapHandler wraps another handler that may be swapped out -// dynamically at runtime in a thread-safe fashion. -type swapHandler struct { - handler atomic.Value -} - -func (h *swapHandler) Log(r *Record) error { - return (*h.handler.Load().(*Handler)).Log(r) -} - -func (h *swapHandler) Swap(newHandler Handler) { - h.handler.Store(&newHandler) -} - -func (h *swapHandler) Get() Handler { - return *h.handler.Load().(*Handler) -} diff --git a/log/logger.go b/log/logger.go deleted file mode 100644 index 276d6969e..000000000 --- a/log/logger.go +++ /dev/null @@ -1,245 +0,0 @@ -package log - -import ( - "fmt" - "os" - "time" - - "github.com/go-stack/stack" -) - -const timeKey = "t" -const lvlKey = "lvl" -const msgKey = "msg" -const ctxKey = "ctx" -const errorKey = "LOG15_ERROR" -const skipLevel = 2 - -type Lvl int - -const ( - LvlCrit Lvl = iota - LvlError - LvlWarn - LvlInfo - LvlDebug - LvlTrace -) - -// AlignedString returns a 5-character string containing the name of a Lvl. -func (l Lvl) AlignedString() string { - switch l { - case LvlTrace: - return "TRACE" - case LvlDebug: - return "DEBUG" - case LvlInfo: - return "INFO " - case LvlWarn: - return "WARN " - case LvlError: - return "ERROR" - case LvlCrit: - return "CRIT " - default: - panic("bad level") - } -} - -// Strings returns the name of a Lvl. -func (l Lvl) String() string { - switch l { - case LvlTrace: - return "trce" - case LvlDebug: - return "dbug" - case LvlInfo: - return "info" - case LvlWarn: - return "warn" - case LvlError: - return "eror" - case LvlCrit: - return "crit" - default: - panic("bad level") - } -} - -// LvlFromString returns the appropriate Lvl from a string name. -// Useful for parsing command line args and configuration files. -func LvlFromString(lvlString string) (Lvl, error) { - switch lvlString { - case "trace", "trce": - return LvlTrace, nil - case "debug", "dbug": - return LvlDebug, nil - case "info": - return LvlInfo, nil - case "warn": - return LvlWarn, nil - case "error", "eror": - return LvlError, nil - case "crit": - return LvlCrit, nil - default: - return LvlDebug, fmt.Errorf("unknown level: %v", lvlString) - } -} - -// A Record is what a Logger asks its handler to write -type Record struct { - Time time.Time - Lvl Lvl - Msg string - Ctx []interface{} - Call stack.Call - KeyNames RecordKeyNames -} - -// RecordKeyNames gets stored in a Record when the write function is executed. -type RecordKeyNames struct { - Time string - Msg string - Lvl string - Ctx string -} - -// A Logger writes key/value pairs to a Handler -type Logger interface { - // New returns a new Logger that has this logger's context plus the given context - New(ctx ...interface{}) Logger - - // GetHandler gets the handler associated with the logger. - GetHandler() Handler - - // SetHandler updates the logger to write records to the specified handler. - SetHandler(h Handler) - - // Log a message at the given level with context key/value pairs - Trace(msg string, ctx ...interface{}) - Debug(msg string, ctx ...interface{}) - Info(msg string, ctx ...interface{}) - Warn(msg string, ctx ...interface{}) - Error(msg string, ctx ...interface{}) - Crit(msg string, ctx ...interface{}) -} - -type logger struct { - ctx []interface{} - h *swapHandler -} - -func (l *logger) write(msg string, lvl Lvl, ctx []interface{}, skip int) { - l.h.Log(&Record{ - Time: time.Now(), - Lvl: lvl, - Msg: msg, - Ctx: newContext(l.ctx, ctx), - Call: stack.Caller(skip), - KeyNames: RecordKeyNames{ - Time: timeKey, - Msg: msgKey, - Lvl: lvlKey, - Ctx: ctxKey, - }, - }) -} - -func (l *logger) New(ctx ...interface{}) Logger { - child := &logger{newContext(l.ctx, ctx), new(swapHandler)} - child.SetHandler(l.h) - return child -} - -func newContext(prefix []interface{}, suffix []interface{}) []interface{} { - normalizedSuffix := normalize(suffix) - newCtx := make([]interface{}, len(prefix)+len(normalizedSuffix)) - n := copy(newCtx, prefix) - copy(newCtx[n:], normalizedSuffix) - return newCtx -} - -func (l *logger) Trace(msg string, ctx ...interface{}) { - l.write(msg, LvlTrace, ctx, skipLevel) -} - -func (l *logger) Debug(msg string, ctx ...interface{}) { - l.write(msg, LvlDebug, ctx, skipLevel) -} - -func (l *logger) Info(msg string, ctx ...interface{}) { - l.write(msg, LvlInfo, ctx, skipLevel) -} - -func (l *logger) Warn(msg string, ctx ...interface{}) { - l.write(msg, LvlWarn, ctx, skipLevel) -} - -func (l *logger) Error(msg string, ctx ...interface{}) { - l.write(msg, LvlError, ctx, skipLevel) -} - -func (l *logger) Crit(msg string, ctx ...interface{}) { - l.write(msg, LvlCrit, ctx, skipLevel) - os.Exit(1) -} - -func (l *logger) GetHandler() Handler { - return l.h.Get() -} - -func (l *logger) SetHandler(h Handler) { - l.h.Swap(h) -} - -func normalize(ctx []interface{}) []interface{} { - // if the caller passed a Ctx object, then expand it - if len(ctx) == 1 { - if ctxMap, ok := ctx[0].(Ctx); ok { - ctx = ctxMap.toArray() - } - } - - // ctx needs to be even because it's a series of key/value pairs - // no one wants to check for errors on logging functions, - // so instead of erroring on bad input, we'll just make sure - // that things are the right length and users can fix bugs - // when they see the output looks wrong - if len(ctx)%2 != 0 { - ctx = append(ctx, nil, errorKey, "Normalized odd number of arguments by adding nil") - } - - return ctx -} - -// Lazy allows you to defer calculation of a logged value that is expensive -// to compute until it is certain that it must be evaluated with the given filters. -// -// Lazy may also be used in conjunction with a Logger's New() function -// to generate a child logger which always reports the current value of changing -// state. -// -// You may wrap any function which takes no arguments to Lazy. It may return any -// number of values of any type. -type Lazy struct { - Fn interface{} -} - -// Ctx is a map of key/value pairs to pass as context to a log function -// Use this only if you really need greater safety around the arguments you pass -// to the logging functions. -type Ctx map[string]interface{} - -func (c Ctx) toArray() []interface{} { - arr := make([]interface{}, len(c)*2) - - i := 0 - for k, v := range c { - arr[i] = k - arr[i+1] = v - i += 2 - } - - return arr -} diff --git a/log/root.go b/log/root.go deleted file mode 100644 index 9fb4c5ae0..000000000 --- a/log/root.go +++ /dev/null @@ -1,70 +0,0 @@ -package log - -import ( - "os" -) - -var ( - root = &logger{[]interface{}{}, new(swapHandler)} - StdoutHandler = StreamHandler(os.Stdout, LogfmtFormat()) - StderrHandler = StreamHandler(os.Stderr, LogfmtFormat()) -) - -func init() { - root.SetHandler(DiscardHandler()) -} - -// New returns a new logger with the given context. -// New is a convenient alias for Root().New -func New(ctx ...interface{}) Logger { - return root.New(ctx...) -} - -// Root returns the root logger -func Root() Logger { - return root -} - -// The following functions bypass the exported logger methods (logger.Debug, -// etc.) to keep the call depth the same for all paths to logger.write so -// runtime.Caller(2) always refers to the call site in client code. - -// Trace is a convenient alias for Root().Trace -func Trace(msg string, ctx ...interface{}) { - root.write(msg, LvlTrace, ctx, skipLevel) -} - -// Debug is a convenient alias for Root().Debug -func Debug(msg string, ctx ...interface{}) { - root.write(msg, LvlDebug, ctx, skipLevel) -} - -// Info is a convenient alias for Root().Info -func Info(msg string, ctx ...interface{}) { - root.write(msg, LvlInfo, ctx, skipLevel) -} - -// Warn is a convenient alias for Root().Warn -func Warn(msg string, ctx ...interface{}) { - root.write(msg, LvlWarn, ctx, skipLevel) -} - -// Error is a convenient alias for Root().Error -func Error(msg string, ctx ...interface{}) { - root.write(msg, LvlError, ctx, skipLevel) -} - -// Crit is a convenient alias for Root().Crit -func Crit(msg string, ctx ...interface{}) { - root.write(msg, LvlCrit, ctx, skipLevel) - os.Exit(1) -} - -// Output is a convenient alias for write, allowing for the modification of -// the calldepth (number of stack frames to skip). -// calldepth influences the reported line number of the log message. -// A calldepth of zero reports the immediate caller of Output. -// Non-zero calldepth skips as many stack frames. -func Output(msg string, lvl Lvl, calldepth int, ctx ...interface{}) { - root.write(msg, lvl, ctx, calldepth+skipLevel) -} diff --git a/log/syslog.go b/log/syslog.go deleted file mode 100644 index 71a17b30b..000000000 --- a/log/syslog.go +++ /dev/null @@ -1,57 +0,0 @@ -// +build !windows,!plan9 - -package log - -import ( - "log/syslog" - "strings" -) - -// SyslogHandler opens a connection to the system syslog daemon by calling -// syslog.New and writes all records to it. -func SyslogHandler(priority syslog.Priority, tag string, fmtr Format) (Handler, error) { - wr, err := syslog.New(priority, tag) - return sharedSyslog(fmtr, wr, err) -} - -// SyslogNetHandler opens a connection to a log daemon over the network and writes -// all log records to it. -func SyslogNetHandler(net, addr string, priority syslog.Priority, tag string, fmtr Format) (Handler, error) { - wr, err := syslog.Dial(net, addr, priority, tag) - return sharedSyslog(fmtr, wr, err) -} - -func sharedSyslog(fmtr Format, sysWr *syslog.Writer, err error) (Handler, error) { - if err != nil { - return nil, err - } - h := FuncHandler(func(r *Record) error { - var syslogFn = sysWr.Info - switch r.Lvl { - case LvlCrit: - syslogFn = sysWr.Crit - case LvlError: - syslogFn = sysWr.Err - case LvlWarn: - syslogFn = sysWr.Warning - case LvlInfo: - syslogFn = sysWr.Info - case LvlDebug: - syslogFn = sysWr.Debug - case LvlTrace: - syslogFn = func(m string) error { return nil } // There's no syslog level for trace - } - - s := strings.TrimSpace(string(fmtr.Format(r))) - return syslogFn(s) - }) - return LazyHandler(&closingHandler{sysWr, h}), nil -} - -func (m muster) SyslogHandler(priority syslog.Priority, tag string, fmtr Format) Handler { - return must(SyslogHandler(priority, tag, fmtr)) -} - -func (m muster) SyslogNetHandler(net, addr string, priority syslog.Priority, tag string, fmtr Format) Handler { - return must(SyslogNetHandler(net, addr, priority, tag, fmtr)) -} diff --git a/metrics/cpu_enabled.go b/metrics/cpu_enabled.go index 840688157..f4e01cc67 100644 --- a/metrics/cpu_enabled.go +++ b/metrics/cpu_enabled.go @@ -19,7 +19,7 @@ package metrics import ( - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/process" ) diff --git a/metrics/cpu_syscall.go b/metrics/cpu_syscall.go index f81d97a60..4ec9c8967 100644 --- a/metrics/cpu_syscall.go +++ b/metrics/cpu_syscall.go @@ -21,7 +21,7 @@ package metrics import ( "syscall" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/shirou/gopsutil/v3/process" ) diff --git a/metrics/exp/exp.go b/metrics/exp/exp.go index 48d614c8d..77790ceaf 100644 --- a/metrics/exp/exp.go +++ b/metrics/exp/exp.go @@ -8,9 +8,9 @@ import ( "net/http" "sync" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/metrics/prometheus" + "github.com/ledgerwatch/log/v3" prometheus2 "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) diff --git a/metrics/metrics.go b/metrics/metrics.go index 6ce8de329..cf8fbc6e0 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -14,7 +14,6 @@ import ( "time" "github.com/ledgerwatch/erigon/common/debug" - "github.com/ledgerwatch/erigon/log" "github.com/shirou/gopsutil/v3/mem" "github.com/shirou/gopsutil/v3/process" ) @@ -66,13 +65,11 @@ func init() { for _, enabler := range enablerFlags { if !Enabled && flag == enabler { - log.Info("Enabling metrics collection") Enabled = true } } for _, enabler := range expensiveEnablerFlags { if !EnabledExpensive && flag == enabler { - log.Info("Enabling expensive metrics collection") EnabledExpensive = true } } diff --git a/metrics/prometheus/prometheus.go b/metrics/prometheus/prometheus.go index d531d22f7..6717d6f01 100644 --- a/metrics/prometheus/prometheus.go +++ b/metrics/prometheus/prometheus.go @@ -22,8 +22,8 @@ import ( "net/http" "sort" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" + "github.com/ledgerwatch/log/v3" ) // Handler returns an HTTP handler which dump metrics in Prometheus format. diff --git a/migrations/call_trace_index.go b/migrations/call_trace_index.go index a736fb7b5..1211877c8 100644 --- a/migrations/call_trace_index.go +++ b/migrations/call_trace_index.go @@ -8,7 +8,7 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) var rebuilCallTraceIndex = Migration{ diff --git a/migrations/migrations.go b/migrations/migrations.go index ed57df2ef..bea501779 100644 --- a/migrations/migrations.go +++ b/migrations/migrations.go @@ -10,7 +10,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "github.com/ugorji/go/codec" ) diff --git a/migrations/receipt_cbor.go b/migrations/receipt_cbor.go index 0f84cfaf4..3b03d361e 100644 --- a/migrations/receipt_cbor.go +++ b/migrations/receipt_cbor.go @@ -16,7 +16,7 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/cbor" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" pkg1_common "github.com/ledgerwatch/erigon/common" codec1978 "github.com/ugorji/go/codec" diff --git a/migrations/receipt_repair.go b/migrations/receipt_repair.go index ac3a0c08e..ceb7690c4 100644 --- a/migrations/receipt_repair.go +++ b/migrations/receipt_repair.go @@ -18,8 +18,8 @@ import ( "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/ethdb/cbor" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) func availableReceiptFrom(tx kv.Tx) (uint64, error) { diff --git a/node/config.go b/node/config.go index 60019769e..2127f98ed 100644 --- a/node/config.go +++ b/node/config.go @@ -30,10 +30,10 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/paths" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/node/endpoints.go b/node/endpoints.go index 79b7e8182..1bda5a777 100644 --- a/node/endpoints.go +++ b/node/endpoints.go @@ -21,8 +21,8 @@ import ( "net/http" "time" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" ) // StartHTTPEndpoint starts the HTTP RPC endpoint. diff --git a/node/node.go b/node/node.go index c884e5878..8d231b985 100644 --- a/node/node.go +++ b/node/node.go @@ -30,10 +30,10 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/memdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/migrations" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" "github.com/prometheus/tsdb/fileutil" ) diff --git a/node/node_test.go b/node/node_test.go index a9653b4d6..6af99a310 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -30,9 +30,9 @@ import ( "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" "github.com/stretchr/testify/assert" ) diff --git a/node/rpcstack.go b/node/rpcstack.go index 3ca2d2477..125631cdb 100644 --- a/node/rpcstack.go +++ b/node/rpcstack.go @@ -29,8 +29,8 @@ import ( "sync" "sync/atomic" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" "github.com/rs/cors" ) diff --git a/node/rpcstack_test.go b/node/rpcstack_test.go index e624d4600..babe047a2 100644 --- a/node/rpcstack_test.go +++ b/node/rpcstack_test.go @@ -28,8 +28,8 @@ import ( "github.com/gorilla/websocket" "github.com/ledgerwatch/erigon/internal/testlog" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" "github.com/stretchr/testify/assert" ) diff --git a/p2p/dial.go b/p2p/dial.go index 961b45844..cf40c7ed0 100644 --- a/p2p/dial.go +++ b/p2p/dial.go @@ -30,9 +30,9 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/common/mclock" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/netutil" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/p2p/dial_test.go b/p2p/dial_test.go index 0644b9bb0..dc21d1a47 100644 --- a/p2p/dial_test.go +++ b/p2p/dial_test.go @@ -29,9 +29,9 @@ import ( "github.com/ledgerwatch/erigon/common/mclock" "github.com/ledgerwatch/erigon/internal/testlog" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/netutil" + "github.com/ledgerwatch/log/v3" ) // This test checks that dynamic dials are launched from discovery results. diff --git a/p2p/discover/common.go b/p2p/discover/common.go index 3d9918ca9..642d79016 100644 --- a/p2p/discover/common.go +++ b/p2p/discover/common.go @@ -21,10 +21,10 @@ import ( "net" "github.com/ledgerwatch/erigon/common/mclock" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" "github.com/ledgerwatch/erigon/p2p/netutil" + "github.com/ledgerwatch/log/v3" ) // UDPConn is a network connection on which discovery can operate. diff --git a/p2p/discover/ntp.go b/p2p/discover/ntp.go index cd3c9f7fb..1615313f2 100644 --- a/p2p/discover/ntp.go +++ b/p2p/discover/ntp.go @@ -26,7 +26,7 @@ import ( "time" "github.com/ledgerwatch/erigon/common/debug" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/p2p/discover/table.go b/p2p/discover/table.go index 260315125..549daa373 100644 --- a/p2p/discover/table.go +++ b/p2p/discover/table.go @@ -34,9 +34,9 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/netutil" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/p2p/discover/table_util_test.go b/p2p/discover/table_util_test.go index e328415f9..26097aea8 100644 --- a/p2p/discover/table_util_test.go +++ b/p2p/discover/table_util_test.go @@ -28,9 +28,9 @@ import ( "sync" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" + "github.com/ledgerwatch/log/v3" ) var nullNode *enode.Node diff --git a/p2p/discover/v4_udp.go b/p2p/discover/v4_udp.go index d570bc729..e084e9064 100644 --- a/p2p/discover/v4_udp.go +++ b/p2p/discover/v4_udp.go @@ -31,11 +31,11 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/discover/v4wire" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/netutil" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) // Errors diff --git a/p2p/discover/v4_udp_test.go b/p2p/discover/v4_udp_test.go index beae9237f..d9ee8396c 100644 --- a/p2p/discover/v4_udp_test.go +++ b/p2p/discover/v4_udp_test.go @@ -33,10 +33,10 @@ import ( "time" "github.com/ledgerwatch/erigon/internal/testlog" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/discover/v4wire" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" + "github.com/ledgerwatch/log/v3" ) // shared test variables @@ -568,7 +568,7 @@ func startLocalhostV4(t *testing.T, cfg Config) *UDPv4 { // Prefix logs with node ID. lprefix := fmt.Sprintf("(%s)", ln.ID().TerminalString()) - lfmt := log.TerminalFormat(false) + lfmt := log.TerminalFormat() cfg.Log = testlog.Logger(t, log.LvlTrace) cfg.Log.SetHandler(log.FuncHandler(func(r *log.Record) error { t.Logf("%s %s", lprefix, lfmt.Format(r)) diff --git a/p2p/discover/v5_udp.go b/p2p/discover/v5_udp.go index 002794f62..5f11efa03 100644 --- a/p2p/discover/v5_udp.go +++ b/p2p/discover/v5_udp.go @@ -31,11 +31,11 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/common/mclock" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/discover/v5wire" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" "github.com/ledgerwatch/erigon/p2p/netutil" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/p2p/discover/v5_udp_test.go b/p2p/discover/v5_udp_test.go index 3e03625c6..402928e23 100644 --- a/p2p/discover/v5_udp_test.go +++ b/p2p/discover/v5_udp_test.go @@ -31,11 +31,11 @@ import ( "time" "github.com/ledgerwatch/erigon/internal/testlog" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/discover/v5wire" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) // Real sockets, real crypto: this test checks end-to-end connectivity for UDPv5. @@ -86,7 +86,7 @@ func startLocalhostV5(t *testing.T, cfg Config) *UDPv5 { // Prefix logs with node ID. lprefix := fmt.Sprintf("(%s)", ln.ID().TerminalString()) - lfmt := log.TerminalFormat(false) + lfmt := log.TerminalFormat() cfg.Log = testlog.Logger(t, log.LvlTrace) cfg.Log.SetHandler(log.FuncHandler(func(r *log.Record) error { t.Logf("%s %s", lprefix, lfmt.Format(r)) diff --git a/p2p/dnsdisc/client.go b/p2p/dnsdisc/client.go index 4d130b748..1005980e2 100644 --- a/p2p/dnsdisc/client.go +++ b/p2p/dnsdisc/client.go @@ -29,9 +29,9 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/ledgerwatch/erigon/common/mclock" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" + "github.com/ledgerwatch/log/v3" "golang.org/x/time/rate" ) diff --git a/p2p/dnsdisc/client_test.go b/p2p/dnsdisc/client_test.go index 1aaf83f84..d44198d01 100644 --- a/p2p/dnsdisc/client_test.go +++ b/p2p/dnsdisc/client_test.go @@ -29,9 +29,9 @@ import ( "github.com/ledgerwatch/erigon/common/mclock" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/internal/testlog" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/p2p/enode/localnode.go b/p2p/enode/localnode.go index 05045a198..187d47f3c 100644 --- a/p2p/enode/localnode.go +++ b/p2p/enode/localnode.go @@ -26,9 +26,9 @@ import ( "sync/atomic" "time" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enr" "github.com/ledgerwatch/erigon/p2p/netutil" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/p2p/enode/nodedb.go b/p2p/enode/nodedb.go index 0a7a2190b..3e96d8fce 100644 --- a/p2p/enode/nodedb.go +++ b/p2p/enode/nodedb.go @@ -33,8 +33,8 @@ import ( "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/common" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) // Keys in the node database. diff --git a/p2p/nat/nat.go b/p2p/nat/nat.go index 486f1157e..19daacfa4 100644 --- a/p2p/nat/nat.go +++ b/p2p/nat/nat.go @@ -25,7 +25,7 @@ import ( "sync" "time" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" natpmp "github.com/jackpal/go-nat-pmp" ) diff --git a/p2p/peer.go b/p2p/peer.go index a3b1434c8..7863b4141 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -28,11 +28,11 @@ import ( "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/common/mclock" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/metrics" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) var ( diff --git a/p2p/peer_test.go b/p2p/peer_test.go index 8ba4dda87..21e0a4792 100644 --- a/p2p/peer_test.go +++ b/p2p/peer_test.go @@ -28,9 +28,9 @@ import ( "testing" "time" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" + "github.com/ledgerwatch/log/v3" ) var discard = Protocol{ diff --git a/p2p/server.go b/p2p/server.go index 98de96e08..c6723b905 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -37,12 +37,12 @@ import ( "github.com/ledgerwatch/erigon/common/mclock" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/discover" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" "github.com/ledgerwatch/erigon/p2p/nat" "github.com/ledgerwatch/erigon/p2p/netutil" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/p2p/server_test.go b/p2p/server_test.go index d4630b14d..0e89966a2 100644 --- a/p2p/server_test.go +++ b/p2p/server_test.go @@ -29,10 +29,10 @@ import ( "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/internal/testlog" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" "github.com/ledgerwatch/erigon/p2p/rlpx" + "github.com/ledgerwatch/log/v3" ) type testTransport struct { diff --git a/p2p/simulations/adapters/exec.go b/p2p/simulations/adapters/exec.go index 98e6d28f3..8533dc140 100644 --- a/p2p/simulations/adapters/exec.go +++ b/p2p/simulations/adapters/exec.go @@ -36,11 +36,11 @@ import ( "github.com/docker/docker/pkg/reexec" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" "github.com/gorilla/websocket" ) @@ -382,9 +382,9 @@ type execNodeConfig struct { func initLogging() { // Initialize the logging by default first. - glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.LogfmtFormat())) - glogger.Verbosity(log.LvlInfo) - log.Root().SetHandler(glogger) + //glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.LogfmtFormat())) + //glogger.Verbosity(log.LvlInfo) + //log.Root().SetHandler(glogger) confEnv := os.Getenv(envNodeConfig) if confEnv == "" { @@ -394,22 +394,25 @@ func initLogging() { if err := json.Unmarshal([]byte(confEnv), &conf); err != nil { return } - var writer = os.Stderr - if conf.Node.LogFile != "" { - logWriter, err := os.Create(conf.Node.LogFile) - if err != nil { - return - } - writer = logWriter - } + //var writer = os.Stderr + //if conf.Node.LogFile != "" { + //logWriter, err := os.Create(conf.Node.LogFile) + //if err != nil { + // return + //} + //writer = logWriter + //} var verbosity = log.LvlInfo if conf.Node.LogVerbosity <= log.LvlTrace && conf.Node.LogVerbosity >= log.LvlCrit { verbosity = conf.Node.LogVerbosity } + + log.Root().SetHandler(log.LvlFilterHandler(verbosity, log.StderrHandler)) + // Reinitialize the logger - glogger = log.NewGlogHandler(log.StreamHandler(writer, log.TerminalFormat(true))) - glogger.Verbosity(verbosity) - log.Root().SetHandler(glogger) + //glogger = log.NewGlogHandler(log.StreamHandler(writer, log.TerminalFormat())) + //glogger.Verbosity(verbosity) + //log.Root().SetHandler(glogger) } // execP2PNode starts a simulation node when the current binary is executed with diff --git a/p2p/simulations/adapters/inproc.go b/p2p/simulations/adapters/inproc.go index 15372c04d..d51cc7451 100644 --- a/p2p/simulations/adapters/inproc.go +++ b/p2p/simulations/adapters/inproc.go @@ -25,12 +25,12 @@ import ( "sync" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/simulations/pipes" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" "github.com/gorilla/websocket" ) diff --git a/p2p/simulations/adapters/types.go b/p2p/simulations/adapters/types.go index 074e1a9a9..30478ded2 100644 --- a/p2p/simulations/adapters/types.go +++ b/p2p/simulations/adapters/types.go @@ -28,12 +28,12 @@ import ( "github.com/docker/docker/pkg/reexec" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/enr" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/log/v3" "github.com/gorilla/websocket" ) diff --git a/p2p/simulations/examples/ping-pong.go b/p2p/simulations/examples/ping-pong.go index 06bc95612..d21dad228 100644 --- a/p2p/simulations/examples/ping-pong.go +++ b/p2p/simulations/examples/ping-pong.go @@ -25,12 +25,12 @@ import ( "sync/atomic" "time" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/simulations" "github.com/ledgerwatch/erigon/p2p/simulations/adapters" + "github.com/ledgerwatch/log/v3" ) var adapterType = flag.String("adapter", "sim", `node adapter to use (one of "sim", "exec" or "docker")`) @@ -41,7 +41,7 @@ func main() { flag.Parse() // set the log level to Trace - log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(false)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) // register a single ping-pong service services := map[string]adapters.LifecycleConstructor{ diff --git a/p2p/simulations/http_test.go b/p2p/simulations/http_test.go index 5bc1be018..354235845 100644 --- a/p2p/simulations/http_test.go +++ b/p2p/simulations/http_test.go @@ -30,20 +30,19 @@ import ( "time" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/simulations/adapters" "github.com/ledgerwatch/erigon/rpc" - "github.com/mattn/go-colorable" + "github.com/ledgerwatch/log/v3" ) func TestMain(m *testing.M) { loglevel := flag.Int("loglevel", 2, "verbosity of logs") flag.Parse() - log.PrintOrigins(true) - log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(colorable.NewColorableStderr(), log.TerminalFormat(true)))) + //log.PrintOrigins(true) + log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StderrHandler)) os.Exit(m.Run()) } diff --git a/p2p/simulations/mocker.go b/p2p/simulations/mocker.go index 0b3aa28a8..a3328e0cb 100644 --- a/p2p/simulations/mocker.go +++ b/p2p/simulations/mocker.go @@ -24,9 +24,9 @@ import ( "sync" "time" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/simulations/adapters" + "github.com/ledgerwatch/log/v3" ) //a map of mocker names to its function diff --git a/p2p/simulations/network.go b/p2p/simulations/network.go index c7b86a849..47458664f 100644 --- a/p2p/simulations/network.go +++ b/p2p/simulations/network.go @@ -28,10 +28,10 @@ import ( "time" "github.com/ledgerwatch/erigon/event" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/simulations/adapters" + "github.com/ledgerwatch/log/v3" ) var DialBanTimeout = 200 * time.Millisecond diff --git a/p2p/simulations/network_test.go b/p2p/simulations/network_test.go index b35564328..b780226cc 100644 --- a/p2p/simulations/network_test.go +++ b/p2p/simulations/network_test.go @@ -28,10 +28,10 @@ import ( "time" "github.com/ledgerwatch/erigon/common/fdlimit" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/p2p/enode" "github.com/ledgerwatch/erigon/p2p/simulations/adapters" + "github.com/ledgerwatch/log/v3" ) // Tests that a created snapshot with a minimal service only contains the expected connections diff --git a/rpc/client.go b/rpc/client.go index aed444239..76b8c14f6 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -28,7 +28,7 @@ import ( "sync/atomic" "time" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) var ( diff --git a/rpc/client_test.go b/rpc/client_test.go index b9a5472dd..64fe5470b 100644 --- a/rpc/client_test.go +++ b/rpc/client_test.go @@ -31,7 +31,7 @@ import ( "time" "github.com/davecgh/go-spew/spew" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) func TestClientRequest(t *testing.T) { diff --git a/rpc/handler.go b/rpc/handler.go index 7b90783d1..89716bd15 100644 --- a/rpc/handler.go +++ b/rpc/handler.go @@ -26,7 +26,7 @@ import ( "time" jsoniter "github.com/json-iterator/go" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) // handler handles JSON-RPC messages. There is one handler per connection. Note that diff --git a/rpc/ipc.go b/rpc/ipc.go index 136807708..a0a5786ff 100644 --- a/rpc/ipc.go +++ b/rpc/ipc.go @@ -19,8 +19,8 @@ package rpc import ( "net" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/p2p/netutil" + "github.com/ledgerwatch/log/v3" ) // ServeListener accepts connections on l, serving JSON-RPC on them. diff --git a/rpc/server.go b/rpc/server.go index 4fec17e35..bcfcaa9b5 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -23,7 +23,7 @@ import ( mapset "github.com/deckarep/golang-set" jsoniter "github.com/json-iterator/go" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) const MetadataApi = "rpc" diff --git a/rpc/service.go b/rpc/service.go index ff5226bea..6ed5468a2 100644 --- a/rpc/service.go +++ b/rpc/service.go @@ -27,7 +27,7 @@ import ( "unicode" jsoniter "github.com/json-iterator/go" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) var ( diff --git a/rpc/websocket.go b/rpc/websocket.go index 8c0b6f8a7..18cebc4a0 100644 --- a/rpc/websocket.go +++ b/rpc/websocket.go @@ -29,7 +29,7 @@ import ( mapset "github.com/deckarep/golang-set" "github.com/gorilla/websocket" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/turbo/cli/flags.go b/turbo/cli/flags.go index f3d14543b..40f944c4a 100644 --- a/turbo/cli/flags.go +++ b/turbo/cli/flags.go @@ -11,9 +11,9 @@ import ( "github.com/ledgerwatch/erigon/eth/ethconfig" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/prune" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/turbo/snapshotsync" + "github.com/ledgerwatch/log/v3" "github.com/spf13/pflag" "github.com/urfave/cli" ) diff --git a/turbo/node/node.go b/turbo/node/node.go index e96c5d6b9..28bb8c17f 100644 --- a/turbo/node/node.go +++ b/turbo/node/node.go @@ -6,10 +6,10 @@ import ( "github.com/ledgerwatch/erigon/eth" "github.com/ledgerwatch/erigon/eth/ethconfig" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/node" "github.com/ledgerwatch/erigon/params" erigoncli "github.com/ledgerwatch/erigon/turbo/cli" + "github.com/ledgerwatch/log/v3" "github.com/urfave/cli" ) diff --git a/turbo/remote/sentry_client.go b/turbo/remote/sentry_client.go index a6ace8476..070f2a96b 100644 --- a/turbo/remote/sentry_client.go +++ b/turbo/remote/sentry_client.go @@ -8,7 +8,7 @@ import ( "github.com/golang/protobuf/ptypes/empty" proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry" "github.com/ledgerwatch/erigon/eth/protocols/eth" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" ) diff --git a/turbo/snapshotsync/bodies_snapshot.go b/turbo/snapshotsync/bodies_snapshot.go index f84895868..85b69214c 100644 --- a/turbo/snapshotsync/bodies_snapshot.go +++ b/turbo/snapshotsync/bodies_snapshot.go @@ -16,8 +16,8 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) func GenerateBodiesSnapshot(ctx context.Context, readTX kv.Tx, writeTX kv.RwTx, toBlock uint64) error { diff --git a/turbo/snapshotsync/downloader.go b/turbo/snapshotsync/downloader.go index 19b3ed0a1..c3047969d 100644 --- a/turbo/snapshotsync/downloader.go +++ b/turbo/snapshotsync/downloader.go @@ -18,7 +18,7 @@ import ( "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/debug" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" "golang.org/x/sync/errgroup" ) diff --git a/turbo/snapshotsync/headers_snapshot.go b/turbo/snapshotsync/headers_snapshot.go index e1bd60ff4..f06431a5b 100644 --- a/turbo/snapshotsync/headers_snapshot.go +++ b/turbo/snapshotsync/headers_snapshot.go @@ -14,7 +14,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) func CreateHeadersSnapshot(ctx context.Context, readTX kv.Tx, toBlock uint64, snapshotPath string) error { diff --git a/turbo/snapshotsync/logger.go b/turbo/snapshotsync/logger.go index 65821763c..793d60efc 100644 --- a/turbo/snapshotsync/logger.go +++ b/turbo/snapshotsync/logger.go @@ -2,7 +2,7 @@ package snapshotsync import ( lg "github.com/anacrolix/log" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) func init() { diff --git a/turbo/snapshotsync/postprocessing.go b/turbo/snapshotsync/postprocessing.go index 6e445be78..dad64c1a7 100644 --- a/turbo/snapshotsync/postprocessing.go +++ b/turbo/snapshotsync/postprocessing.go @@ -16,8 +16,8 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) const ( diff --git a/turbo/snapshotsync/postprocessing_test.go b/turbo/snapshotsync/postprocessing_test.go index 1f7024f05..f47840f0f 100644 --- a/turbo/snapshotsync/postprocessing_test.go +++ b/turbo/snapshotsync/postprocessing_test.go @@ -12,8 +12,8 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" mdbx2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" "github.com/stretchr/testify/require" "github.com/torquem-ch/mdbx-go/mdbx" ) diff --git a/turbo/snapshotsync/snapshot_builder.go b/turbo/snapshotsync/snapshot_builder.go index e1ab7ec3b..621ae4aaf 100644 --- a/turbo/snapshotsync/snapshot_builder.go +++ b/turbo/snapshotsync/snapshot_builder.go @@ -19,8 +19,8 @@ import ( "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) func NewMigrator(snapshotDir string, currentSnapshotBlock uint64, currentSnapshotInfohash []byte) *SnapshotMigrator { diff --git a/turbo/snapshotsync/snapshot_builder_test.go b/turbo/snapshotsync/snapshot_builder_test.go index c81e5b748..e7341587b 100644 --- a/turbo/snapshotsync/snapshot_builder_test.go +++ b/turbo/snapshotsync/snapshot_builder_test.go @@ -25,8 +25,8 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" "github.com/stretchr/testify/require" ) @@ -44,7 +44,7 @@ func TestSnapshotMigratorStageAsync(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("fix me on win please") // after remove ChainReader from consensus engine - this test can be changed to create less databases, then can enable on win. now timeout after 20min } - //log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + //log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) logger := log.New() var err error dir := t.TempDir() @@ -383,7 +383,7 @@ func TestSnapshotMigratorStageSyncMode(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("fix me on win please") // after remove ChainReader from consensus engine - this test can be changed to create less databases, then can enable on win. now timeout after 20min } - //log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + //log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) logger := log.New() var err error dir := t.TempDir() @@ -1023,7 +1023,7 @@ func TestPruneBlocks(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("fix me on win please") // after remove ChainReader from consensus engine - this test can be changed to create less databases, then can enable on win. now timeout after 20min } - //log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + //log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) logger := log.New() var err error dir := t.TempDir() @@ -1292,7 +1292,7 @@ func TestBodySnapshotSyncMigration(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("fix me on win please") // after remove ChainReader from consensus engine - this test can be changed to create less databases, then can enable on win. now timeout after 20min } - //log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + //log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) logger := log.New() var err error dir := t.TempDir() diff --git a/turbo/snapshotsync/wrapdb.go b/turbo/snapshotsync/wrapdb.go index c61898d8b..afa4d5001 100644 --- a/turbo/snapshotsync/wrapdb.go +++ b/turbo/snapshotsync/wrapdb.go @@ -10,7 +10,7 @@ import ( "github.com/ledgerwatch/erigon/ethdb/kv" kv2 "github.com/ledgerwatch/erigon/ethdb/mdbx" "github.com/ledgerwatch/erigon/ethdb/snapshotdb" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) var ( diff --git a/turbo/stages/blockchain_test.go b/turbo/stages/blockchain_test.go index c1e580c2a..fc73e3ff1 100644 --- a/turbo/stages/blockchain_test.go +++ b/turbo/stages/blockchain_test.go @@ -23,7 +23,6 @@ import ( "fmt" "math" "math/big" - "os" "testing" "github.com/holiman/uint256" @@ -44,9 +43,9 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/stages" + "github.com/ledgerwatch/log/v3" ) // So we can deterministically seed different blockchains @@ -1075,7 +1074,7 @@ func TestBlockchainHeaderchainReorgConsistency(t *testing.T) { // forking point is not available any more. func TestLargeReorgTrieGC(t *testing.T) { defer log.Root().SetHandler(log.Root().GetHandler()) - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) // Generate the original common chain segment and the two competing forks m, m2 := stages.Mock(t), stages.Mock(t) @@ -1136,7 +1135,7 @@ func TestLargeReorgTrieGC(t *testing.T) { // - https://github.com/ethereum/go-ethereum/pull/18988 func TestLowDiffLongChain(t *testing.T) { defer log.Root().SetHandler(log.Root().GetHandler()) - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) // Generate a canonical chain to act as the main dataset m := stages.Mock(t) diff --git a/turbo/stages/bodydownload/body_algos.go b/turbo/stages/bodydownload/body_algos.go index 7a5bec2a3..86e44e26e 100644 --- a/turbo/stages/bodydownload/body_algos.go +++ b/turbo/stages/bodydownload/body_algos.go @@ -14,9 +14,9 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/turbo/adapter" "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" + "github.com/ledgerwatch/log/v3" ) const BlockBufferSize = 128 diff --git a/turbo/stages/chain_makers_test.go b/turbo/stages/chain_makers_test.go index 9505544f7..1216e0a3b 100644 --- a/turbo/stages/chain_makers_test.go +++ b/turbo/stages/chain_makers_test.go @@ -29,8 +29,8 @@ import ( "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/crypto" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" + "github.com/ledgerwatch/log/v3" ) func TestGenerateChain(t *testing.T) { diff --git a/turbo/stages/headerdownload/header_algos.go b/turbo/stages/headerdownload/header_algos.go index 5883ce6cb..90d483435 100644 --- a/turbo/stages/headerdownload/header_algos.go +++ b/turbo/stages/headerdownload/header_algos.go @@ -21,9 +21,9 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/log/v3" ) // Implements sort.Interface so we can sort the incoming header in the message by block height diff --git a/turbo/stages/mock_sentry.go b/turbo/stages/mock_sentry.go index 5069f5b09..581622bc2 100644 --- a/turbo/stages/mock_sentry.go +++ b/turbo/stages/mock_sentry.go @@ -32,7 +32,6 @@ import ( "github.com/ledgerwatch/erigon/ethdb/memdb" "github.com/ledgerwatch/erigon/ethdb/privateapi" "github.com/ledgerwatch/erigon/ethdb/prune" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/remote" @@ -41,6 +40,7 @@ import ( "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" "github.com/ledgerwatch/erigon/turbo/stages/txpropagate" "github.com/ledgerwatch/erigon/turbo/txpool" + "github.com/ledgerwatch/log/v3" "google.golang.org/protobuf/types/known/emptypb" ) @@ -358,7 +358,7 @@ func Mock(t *testing.T) *MockSentry { } func (ms *MockSentry) EnableLogs() { - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) ms.t.Cleanup(func() { log.Root().SetHandler(log.Root().GetHandler()) }) diff --git a/turbo/stages/sentry_mock_test.go b/turbo/stages/sentry_mock_test.go index e090109cc..206f04729 100644 --- a/turbo/stages/sentry_mock_test.go +++ b/turbo/stages/sentry_mock_test.go @@ -2,7 +2,6 @@ package stages_test import ( "math/big" - "os" "testing" "github.com/holiman/uint256" @@ -12,10 +11,10 @@ import ( "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/protocols/eth" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/stages" + "github.com/ledgerwatch/log/v3" "github.com/stretchr/testify/require" ) @@ -25,7 +24,7 @@ func TestEmptyStageSync(t *testing.T) { func TestHeaderStep(t *testing.T) { defer log.Root().SetHandler(log.Root().GetHandler()) - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) m := stages.Mock(t) chain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 100, func(i int, b *core.BlockGen) { @@ -66,7 +65,7 @@ func TestHeaderStep(t *testing.T) { func TestMineBlockWith1Tx(t *testing.T) { t.Skip("revive me") defer log.Root().SetHandler(log.Root().GetHandler()) - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) require, m := require.New(t), stages.Mock(t) chain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 1, func(i int, b *core.BlockGen) { @@ -132,7 +131,7 @@ func TestMineBlockWith1Tx(t *testing.T) { func TestReorg(t *testing.T) { defer log.Root().SetHandler(log.Root().GetHandler()) - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) m := stages.Mock(t) chain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 10, func(i int, b *core.BlockGen) { @@ -313,7 +312,7 @@ func TestReorg(t *testing.T) { func TestAnchorReplace(t *testing.T) { defer log.Root().SetHandler(log.Root().GetHandler()) - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) m := stages.Mock(t) chain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 10, func(i int, b *core.BlockGen) { @@ -412,7 +411,7 @@ func TestAnchorReplace(t *testing.T) { func TestAnchorReplace2(t *testing.T) { defer log.Root().SetHandler(log.Root().GetHandler()) - log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) + log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StderrHandler)) m := stages.Mock(t) chain, err := core.GenerateChain(m.ChainConfig, m.Genesis, m.Engine, m.DB, 10, func(i int, b *core.BlockGen) { b.SetCoinbase(common.Address{1}) diff --git a/turbo/stages/stageloop.go b/turbo/stages/stageloop.go index 4b98d9a8d..ed6606e15 100644 --- a/turbo/stages/stageloop.go +++ b/turbo/stages/stageloop.go @@ -18,11 +18,11 @@ import ( "github.com/ledgerwatch/erigon/eth/stagedsync" "github.com/ledgerwatch/erigon/eth/stagedsync/stages" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/turbo/shards" "github.com/ledgerwatch/erigon/turbo/snapshotsync" "github.com/ledgerwatch/erigon/turbo/stages/headerdownload" "github.com/ledgerwatch/erigon/turbo/txpool" + "github.com/ledgerwatch/log/v3" ) // StageLoop runs the continuous loop of staged sync diff --git a/turbo/transactions/call.go b/turbo/transactions/call.go index 3f97a6939..c8cedf604 100644 --- a/turbo/transactions/call.go +++ b/turbo/transactions/call.go @@ -16,10 +16,10 @@ import ( "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/ethdb/kv" "github.com/ledgerwatch/erigon/internal/ethapi" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/rpchelper" + "github.com/ledgerwatch/log/v3" ) const callTimeout = 5 * time.Minute diff --git a/turbo/trie/trie.go b/turbo/trie/trie.go index 5d86fb174..77a6efefd 100644 --- a/turbo/trie/trie.go +++ b/turbo/trie/trie.go @@ -27,7 +27,7 @@ import ( "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/ethdb" - "github.com/ledgerwatch/erigon/log" + "github.com/ledgerwatch/log/v3" ) var ( diff --git a/turbo/trie/trie_root.go b/turbo/trie/trie_root.go index bf65cb0fe..a2da9c687 100644 --- a/turbo/trie/trie_root.go +++ b/turbo/trie/trie_root.go @@ -12,8 +12,8 @@ import ( "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/core/types/accounts" "github.com/ledgerwatch/erigon/ethdb/kv" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/turbo/rlphacks" + "github.com/ledgerwatch/log/v3" ) /* diff --git a/turbo/txpool/p2p.go b/turbo/txpool/p2p.go index a5d6adbfa..c0a9b1b8d 100644 --- a/turbo/txpool/p2p.go +++ b/turbo/txpool/p2p.go @@ -19,10 +19,10 @@ import ( "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/eth/fetcher" "github.com/ledgerwatch/erigon/eth/protocols/eth" - "github.com/ledgerwatch/erigon/log" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/remote" "github.com/ledgerwatch/erigon/turbo/stages/txpropagate" + "github.com/ledgerwatch/log/v3" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status"