lotus/journal/sugar.go

18 lines
608 B
Go
Raw Normal View History

2020-07-17 17:54:26 +00:00
package journal
// MaybeRecordEvent is a convenience function that evaluates if the EventType is
// enabled, and if so, it calls the supplier to create the event and
// subsequently journal.RecordEvent on the provided journal to record it.
//
// This is safe to call with a nil Journal, either because the value is nil,
// or because a journal obtained through NilJournal() is in use.
func MaybeRecordEvent(journal Journal, evtType EventType, supplier func() interface{}) {
if journal == nil || journal == nilj {
return
}
2020-07-17 17:54:26 +00:00
if !evtType.Enabled() {
return
}
journal.RecordEvent(evtType, supplier())
2020-07-17 17:54:26 +00:00
}