Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement WithTransaction() method eq. to WithOrder() #164

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
ShopField = "shop"
CheckoutField = "checkout"
OrderField = "order"
TransactionField = "transaction"
CheckoutDeviceField = "checkoutDevice"
DurationField = "duration"
FlakyField = "flaky"
Expand Down Expand Up @@ -90,6 +91,10 @@ func (logger *Logger) WithOrder(order string) *Entry {
return NewEntry(logger).WithField(OrderField, order)
}

func (logger *Logger) WithTransaction(txn string) *Entry {
return NewEntry(logger).WithField(TransactionField, txn)
}

type Entry struct {
*logrus.Entry
}
Expand Down Expand Up @@ -164,6 +169,10 @@ func (entry *Entry) WithOrder(orderID string) *Entry {
return entry.WithField(OrderField, orderID)
}

func (entry *Entry) WithTransaction(txnID string) *Entry {
return entry.WithField(TransactionField, txnID)
}

// Deprecation marks the log entry with type "deprecation". This is used for log entries, that are logged during a
// feature change. Logs with "deprecation" types should not be considered as critical and should only occur temporarily
// during the transition.
Expand Down