@ -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)
@ -25,10 +25,14 @@ func (w *DailyFileWriter) Write(p []byte) (n int, err error) {
now := time.Now()
w.openFile(&now)
if err = w.openFile(&now); err != nil {
} else if now.Unix() >= w.nextDayTime {
w.file.Close()
@ -20,10 +20,16 @@ type FixedSizeFileWriter struct {
func (w *FixedSizeFileWriter) Write(p []byte) (n int, err error) {
w.openCurrentFile()
} else if w.currentSize > w.MaxSize {
if err = w.openCurrentFile(); err != nil {
if w.currentSize > w.MaxSize {
w.openNextFile()
if err = w.openNextFile(); err != nil {
w.currentSize += int64(len(p))