diff --git a/pkg/bg/bg.go b/pkg/bg/bg.go index edbfd2c6a9..69f82e0974 100644 --- a/pkg/bg/bg.go +++ b/pkg/bg/bg.go @@ -4,14 +4,13 @@ package bg import ( "context" "fmt" - "log" "github.com/rs/zerolog" ) type config struct { name string - logger *zerolog.Logger + logger zerolog.Logger } type Opt func(*config) @@ -21,12 +20,16 @@ func WithName(name string) Opt { } func WithLogger(logger zerolog.Logger) Opt { - return func(cfg *config) { cfg.logger = &logger } + return func(cfg *config) { cfg.logger = logger } } // Work emits a new task in the background func Work(ctx context.Context, f func(context.Context) error, opts ...Opt) { - var cfg config + cfg := config{ + name: "", + logger: zerolog.Nop(), + } + for _, opt := range opts { opt(&cfg) } @@ -55,10 +58,5 @@ func logError(err error, cfg config) { name = "no task name specified" } - if cfg.logger == nil { - log.Printf("Error occurred in background task %q: %s \n", name, err.Error()) - return - } - - cfg.logger.Error().Err(err).Str("worker.name", name).Msgf("Error occurred in background task") + cfg.logger.Error().Err(err).Str("worker.name", name).Msgf("Background task failed") } diff --git a/zetaclient/chains/evm/signer/signer.go b/zetaclient/chains/evm/signer/signer.go index 53a43f1cb2..1f90bfed06 100644 --- a/zetaclient/chains/evm/signer/signer.go +++ b/zetaclient/chains/evm/signer/signer.go @@ -163,7 +163,7 @@ func (signer *Signer) Sign( nonce uint64, height uint64, ) (*ethtypes.Transaction, []byte, []byte, error) { - log.Debug().Msgf("Sign: TSS signer: %s", signer.TSS().Pubkey()) + log.Debug().Bytes("tss.pub_key", signer.TSS().Pubkey()).Msg("Sign: TSS signer") // TODO: use EIP-1559 transaction type // https://github.com/zeta-chain/node/issues/1952