Skip to content

Commit

Permalink
add Logs() method to read the logs from MemoryHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
creativeprojects committed Jun 2, 2022
1 parent 42d3fa3 commit 606eaf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions memory_handler.go
Expand Up @@ -32,6 +32,11 @@ func (h *MemoryHandler) SetPrefix(prefix string) Handler {
return h
}

// Logs return a list of all the messages sent to the logger
func (h *MemoryHandler) Logs() []string {
return h.log
}

// Verify interface
var (
_ Handler = &MemoryHandler{}
Expand Down
4 changes: 2 additions & 2 deletions memory_handler_test.go
Expand Up @@ -21,8 +21,8 @@ func TestMemoryHandlerConcurrency(t *testing.T) {
}(i)
}
wg.Wait()
assert.Len(t, handler.log, iterations)
for _, entry := range handler.log {
assert.Len(t, handler.Logs(), iterations)
for _, entry := range handler.Logs() {
assert.Len(t, entry, 7)
}
}

0 comments on commit 606eaf4

Please sign in to comment.