Skip to content

Commit

Permalink
Add helper method to SimpleLogrusHook to get logged lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed Jan 17, 2023
1 parent 2378549 commit f3cecec
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/testutils/logrus_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ func (smh *SimpleLogrusHook) Drain() []logrus.Entry {
return res
}

// Lines returns the logged lines.
func (smh *SimpleLogrusHook) Lines() []string {
entries := smh.Drain()
lines := make([]string, len(entries))
for i, entry := range entries {
lines[i] = entry.Message
}
return lines
}

var _ logrus.Hook = &SimpleLogrusHook{}

// LogContains is a helper function that checks the provided list of log entries
Expand Down

0 comments on commit f3cecec

Please sign in to comment.