Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
chore(BUX-199): remove txID from logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pawellewandowski98 committed Dec 13, 2023
1 parent 2af4b4b commit 2a42f52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion record_tx_strategy_external_incoming_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (strategy *externalIncomingTx) Execute(ctx context.Context, c ClientInterfa

logger.Info().
Str("txID", transaction.ID).
Msgf("External incoming tx execute complete")
Msg("External incoming tx execute complete")
return transaction, nil
}

Expand Down
16 changes: 8 additions & 8 deletions record_tx_strategy_internal_incoming_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (strategy *internalIncomingTx) Execute(ctx context.Context, c ClientInterfa
logger := c.Logger()
logger.Info().
Str("txID", strategy.Tx.ID).
Msgf("InternalIncomingTx.Execute(): start, TxID: %s", strategy.Tx.ID)
Msg("start recording transaction")

// process
transaction := strategy.Tx
Expand All @@ -35,21 +35,21 @@ func (strategy *internalIncomingTx) Execute(ctx context.Context, c ClientInterfa
if err != nil {
logger.Error().
Str("txID", transaction.ID).
Msgf("broadcasting failed, transaction rejected! Reason: %s, TxID: %s", err, transaction.ID)
Msgf("broadcasting failed, transaction rejected! Reason: %s", err)

return nil, fmt.Errorf("broadcasting failed, transaction rejected! Reason: %w, TxID: %s", err, transaction.ID)
return nil, fmt.Errorf("broadcasting failed, transaction rejected! Reason: %w", err)
}
}

logger.Info().
Str("txID", transaction.ID).
Msgf("InternalIncomingTx.Execute(): complete, TxID: %s", transaction.ID)
Msg("complete")
return transaction, nil
}

func (strategy *internalIncomingTx) Validate() error {
if strategy.Tx == nil {
return errors.New("Tx cannot be nil")
return errors.New("tx cannot be nil")
}

return nil // is valid
Expand All @@ -74,23 +74,23 @@ func (strategy *internalIncomingTx) FailOnBroadcastError(forceFail bool) {
func _internalIncomingBroadcast(ctx context.Context, logger *zerolog.Logger, transaction *Transaction, allowErrors bool) error {
logger.Info().
Str("txID", transaction.ID).
Msgf("start broadcast, TxID: %s", transaction.ID)
Msg("start broadcast")

syncTx := transaction.syncTransaction
err := broadcastSyncTransaction(ctx, syncTx)

if err == nil {
logger.Info().
Str("txID", transaction.ID).
Msgf("broadcast complete, TxID: %s", transaction.ID)
Msg("broadcast complete")

return nil
}

if allowErrors {
logger.Warn().
Str("txID", transaction.ID).
Msgf("broadcasting failed, next try will be handled by task manager. Reason: %s, TxID: %s", err, transaction.ID)
Msgf("broadcasting failed, next try will be handled by task manager. Reason: %s", err)

// ignore broadcast error - will be repeted by task manager
return nil
Expand Down
14 changes: 7 additions & 7 deletions record_tx_strategy_outgoing_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (strategy *outgoingTx) Execute(ctx context.Context, c ClientInterface, opts
logger := c.Logger()
logger.Info().
Str("txID", strategy.TxID()).
Msgf("OutgoingTx.Execute(): start, TxID: %s", strategy.TxID())
Msg("start recording transaction")

// create
transaction, err := _createOutgoingTxToRecord(ctx, strategy, c, opts)
Expand Down Expand Up @@ -190,35 +190,35 @@ func _getP2pSyncStatus(tx *Transaction) SyncStatus {
func _outgoingNotifyP2p(ctx context.Context, logger *zerolog.Logger, tx *Transaction) error {
logger.Info().
Str("txID", tx.ID).
Msgf("start p2p, TxID: %s", tx.ID)
Msg("start p2p")

if err := processP2PTransaction(ctx, tx.syncTransaction, tx); err != nil {
logger.Error().
Str("txID", tx.ID).
Msgf("processP2PTransaction failed. Reason: %s, TxID: %s", err, tx.ID)
Msgf("processP2PTransaction failed. Reason: %s", err)

return err
}

logger.Info().
Str("txID", tx.ID).
Msgf("p2p complete, TxID: %s", tx.ID)
Msg("p2p complete")
return nil
}

func _outgoingBroadcast(ctx context.Context, logger *zerolog.Logger, tx *Transaction) {
logger.Info().
Str("txID", tx.ID).
Msgf("OutgoingTx.Execute(): start broadcast, TxID: %s", tx.ID)
Msg("start broadcast")

if err := broadcastSyncTransaction(ctx, tx.syncTransaction); err != nil {
// ignore error, transaction will be broadcasted by cron task
logger.Warn().
Str("txID", tx.ID).
Msgf("broadcasting failed, next try will be handled by task manager. Reason: %s, TxID: %s", err, tx.ID)
Msgf("broadcasting failed, next try will be handled by task manager. Reason: %s", err)
} else {
logger.Info().
Str("txID", tx.ID).
Msgf("broadcast complete, TxID: %s", tx.ID)
Msg("broadcast complete")
}
}

0 comments on commit 2a42f52

Please sign in to comment.