diff --git a/writers/always_new_file_writer.go b/writers/always_new_file_writer.go index 8402538..64900f6 100644 --- a/writers/always_new_file_writer.go +++ b/writers/always_new_file_writer.go @@ -22,7 +22,9 @@ type AlwaysNewFileWriter struct { // Write implements io.Writer func (w *AlwaysNewFileWriter) Write(p []byte) (n int, err error) { if w.file == nil { - w.openFile() + if err = w.openFile(); err != nil { + return + } } return w.file.Write(p) diff --git a/writers/daily_file_writer.go b/writers/daily_file_writer.go index 72d21ca..5dd52d0 100644 --- a/writers/daily_file_writer.go +++ b/writers/daily_file_writer.go @@ -25,10 +25,14 @@ func (w *DailyFileWriter) Write(p []byte) (n int, err error) { now := time.Now() if w.file == nil { - w.openFile(&now) + if err = w.openFile(&now); err != nil { + return + } } else if now.Unix() >= w.nextDayTime { w.file.Close() - w.openFile(&now) + if err = w.openFile(&now); err != nil { + return + } } return w.file.Write(p) diff --git a/writers/fixed_size_file_writer.go b/writers/fixed_size_file_writer.go index b53fdbf..d96a7a2 100644 --- a/writers/fixed_size_file_writer.go +++ b/writers/fixed_size_file_writer.go @@ -20,10 +20,16 @@ type FixedSizeFileWriter struct { // Write implements io.Writer func (w *FixedSizeFileWriter) Write(p []byte) (n int, err error) { if w.file == nil { - w.openCurrentFile() - } else if w.currentSize > w.MaxSize { + if err = w.openCurrentFile(); err != nil { + return + } + } + + if w.currentSize > w.MaxSize { w.file.Close() - w.openNextFile() + if err = w.openNextFile(); err != nil { + return + } } w.currentSize += int64(len(p))