From e38f6a580186ac0474692304aa924227dbb765bc Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Tue, 2 Aug 2016 12:55:02 +0300 Subject: [PATCH] Do not quite on flush error --- output_file.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/output_file.go b/output_file.go index 044068d..9156ba2 100644 --- a/output_file.go +++ b/output_file.go @@ -8,6 +8,7 @@ import ( "log" "os" "path/filepath" + "runtime/debug" "sort" "strconv" "strings" @@ -208,6 +209,13 @@ func (o *FileOutput) Write(data []byte) (n int, err error) { } func (o *FileOutput) flush() { + // Don't exit on panic + defer func() { + if r := recover(); r != nil { + log.Println("PANIC while file flush: ", r, o, string(debug.Stack())) + } + }() + defer o.mu.Unlock() o.mu.Lock()