diff --git a/logrotate.go b/logrotate.go index 9cac980..4cd6738 100644 --- a/logrotate.go +++ b/logrotate.go @@ -136,7 +136,7 @@ func (l *Logger) Write(p []byte) (n int, err error) { } if l.file == nil { - if err = l.openExistingOrNew(len(p)); err != nil { + if err = l.openExistingOrNew(); err != nil { return 0, err } } @@ -272,7 +272,7 @@ func (l *Logger) backupName(name, nameTimeFormat string, local bool) (string, er // openExistingOrNew opens the logfile if it exists and if the current write // would not put it over MaxBytes. If there is no such file or the write would // put it over the MaxBytes, a new file is created. -func (l *Logger) openExistingOrNew(writeLen int) error { +func (l *Logger) openExistingOrNew() error { l.millRun() filename := l.filename() @@ -284,10 +284,6 @@ func (l *Logger) openExistingOrNew(writeLen int) error { return fmt.Errorf("error getting log file info: %s", err) } - if info.Size()+int64(writeLen) >= l.max(int64(writeLen)) { - return l.rotate() - } - file, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0644) if err != nil { // if we fail to open the old log file for some reason, just ignore