Skip to content
This repository was archived by the owner on Dec 30, 2024. It is now read-only.

Commit 76f3772

Browse files
authored
Merge pull request #12 from Constructor-io/pe-671/error-on-flush-fail
fix: return error if flush fails
2 parents 02582d2 + 520f730 commit 76f3772

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

errors.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package zlogsentry
2+
3+
import (
4+
"errors"
5+
)
6+
7+
var ErrFlushTimeout = errors.New("zlogsentry flush timeout")

writer.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ func (w *Writer) WriteLevel(level zerolog.Level, p []byte) (n int, err error) {
8383
// Close forces client to flush all pending events.
8484
// Can be useful before application exits.
8585
func (w *Writer) Close() error {
86-
w.hub.Flush(w.flushTimeout)
86+
if ok := w.hub.Flush(w.flushTimeout); !ok {
87+
return ErrFlushTimeout
88+
}
8789
return nil
8890
}
8991

0 commit comments

Comments
 (0)