Skip to content

Commit 60d8680

Browse files
committed
Fix the EventLog write to a nil Writer will cause panic
1 parent 7b6b47c commit 60d8680

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

eventlog/event_log.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ func New(w io.Writer) EventLog {
2424
}
2525

2626
func (el *eventLog) Write(event event) error {
27+
if el.w == nil {
28+
return nil
29+
}
2730
_, err := el.w.Write([]byte(fmt.Sprintf("[%s]%s\n", time.Now().Format("2006-01-02 15:04:05.999"), event.String())))
2831
return err
2932
}

0 commit comments

Comments
 (0)