Skip to content

Commit 60a76b7

Browse files
Implement WithTransaction() method eq. to WithOrder() (#164)
1 parent 4a0b0c2 commit 60a76b7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

logger.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const (
1414
ShopField = "shop"
1515
CheckoutField = "checkout"
1616
OrderField = "order"
17+
TransactionField = "transaction"
1718
CheckoutDeviceField = "checkoutDevice"
1819
DurationField = "duration"
1920
FlakyField = "flaky"
@@ -90,6 +91,10 @@ func (logger *Logger) WithOrder(order string) *Entry {
9091
return NewEntry(logger).WithField(OrderField, order)
9192
}
9293

94+
func (logger *Logger) WithTransaction(txn string) *Entry {
95+
return NewEntry(logger).WithField(TransactionField, txn)
96+
}
97+
9398
type Entry struct {
9499
*logrus.Entry
95100
}
@@ -164,6 +169,10 @@ func (entry *Entry) WithOrder(orderID string) *Entry {
164169
return entry.WithField(OrderField, orderID)
165170
}
166171

172+
func (entry *Entry) WithTransaction(txnID string) *Entry {
173+
return entry.WithField(TransactionField, txnID)
174+
}
175+
167176
// Deprecation marks the log entry with type "deprecation". This is used for log entries, that are logged during a
168177
// feature change. Logs with "deprecation" types should not be considered as critical and should only occur temporarily
169178
// during the transition.

0 commit comments

Comments
 (0)