Skip to content

Commit

Permalink
Merge pull request #12 from Constructor-io/pe-671/error-on-flush-fail
Browse files Browse the repository at this point in the history
fix: return error if flush fails
  • Loading branch information
archdx authored Oct 6, 2023
2 parents 02582d2 + 520f730 commit 76f3772
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package zlogsentry

import (
"errors"
)

var ErrFlushTimeout = errors.New("zlogsentry flush timeout")
4 changes: 3 additions & 1 deletion writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ func (w *Writer) WriteLevel(level zerolog.Level, p []byte) (n int, err error) {
// Close forces client to flush all pending events.
// Can be useful before application exits.
func (w *Writer) Close() error {
w.hub.Flush(w.flushTimeout)
if ok := w.hub.Flush(w.flushTimeout); !ok {
return ErrFlushTimeout
}
return nil
}

Expand Down

0 comments on commit 76f3772

Please sign in to comment.