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

Commit

Permalink
Add breadcrumbs support for WriteLevel
Browse files Browse the repository at this point in the history
In 3f53baa we've added Breadcrumb support for Write function.
This makes sure we have the same for WriteLevel.
  • Loading branch information
ezr-ondrej authored Jan 10, 2024
1 parent a41ff05 commit 518c55f
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,26 @@ func (w *Writer) Write(data []byte) (n int, err error) {
// implements zerolog.LevelWriter
func (w *Writer) WriteLevel(level zerolog.Level, p []byte) (n int, err error) {
n = len(p)
if _, enabled := w.levels[level]; !enabled {

event, ok := w.parseLogEvent(p)
if !ok {
return
}
event.Level, ok = levelsMapping[level]
if !ok {
return
}

event, ok := w.parseLogEvent(p)
event.Level = levelsMapping[level]
if _, enabled := w.levels[level]; !enabled {
// if the level is not enabled, add event as a breadcrumb
w.addBreadcrumb(event)
return
}

if ok {
w.hub.CaptureEvent(event)
// should flush before os.Exit
if event.Level == sentry.LevelFatal {
w.hub.Flush(w.flushTimeout)
}
w.hub.CaptureEvent(event)
// should flush before os.Exit
if event.Level == sentry.LevelFatal {
w.hub.Flush(w.flushTimeout)
}
return
}
Expand Down

0 comments on commit 518c55f

Please sign in to comment.