Skip to content

Commit

Permalink
Remove logger pointer from bg package
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 committed Jul 10, 2024
1 parent 380d93c commit 55626c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions pkg/bg/bg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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")
}
2 changes: 1 addition & 1 deletion zetaclient/chains/evm/signer/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 55626c9

Please sign in to comment.