serhiy-storchaka · GitHub

Bug report

In the following example the rotating file handler writes the message in file "test.log" and creates an empty backup file "test.log.1".

import logging.handlers
fh = logging.handlers.RotatingFileHandler('test.log', maxBytes=100, backupCount=1)
fh.emit(logging.makeLogRecord({'msg': 'x'*100}))
fh.close()

I think creating an empty backup file is meaningless. shouldRollover() should return False if self.stream.tell() returns 0 (it happens for just created file).

Linked PRs

Read the original on github.com ↗