From 50135a90affdaf597a2d5a50eaca59f7d3d6559d Mon Sep 17 00:00:00 2001 From: jsvisa Date: Sat, 10 Aug 2024 15:11:47 +0800 Subject: [PATCH] core: set logger after inited Signed-off-by: jsvisa --- core/blockchain.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/blockchain.go b/core/blockchain.go index 68651ecf9e..dc46ee70db 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2514,3 +2514,12 @@ func (bc *BlockChain) GetTrieFlushInterval() time.Duration { func (bc *BlockChain) logger() *tracing.Hooks { return bc.vmConfig.Tracer } + +// SetLogger sets the blockchain tracer for logging and debugging purposes. +// This method should be called during the initialization phase of the blockchain. +// Note: Setting a logger after the blockchain has started processing blocks may +// result in inconsistent or partial logging. It's recommended to set the logger +// before any block processing occurs. +func (bc *BlockChain) SetLogger(logger *tracing.Hooks) { + bc.vmConfig.Tracer = logger +}