Skip to content

Commit

Permalink
Merge pull request #16 from ipfs/feat/log/done-error
Browse files Browse the repository at this point in the history
Add DoneWithErr Method
  • Loading branch information
frrist authored Jan 30, 2018
2 parents 7ce9f81 + c435e57 commit 3437940
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ func (eip *EventInProgress) Done() {
eip.doneFunc(eip.loggables) // create final event with extra data
}

// DoneWithErr creates a new Event entry that includes the duration and appended
// loggables. DoneWithErr accepts an error, if err is non-nil, it is set on
// the EventInProgress. Otherwise the logic is the same as the `Done()` method
func (eip *EventInProgress) DoneWithErr(err error) {
if err != nil {
eip.SetError(err)
}
eip.doneFunc(eip.loggables)
}

// Close is an alias for done
func (eip *EventInProgress) Close() error {
eip.Done()
Expand Down

0 comments on commit 3437940

Please sign in to comment.