shouldRollover overwrites backup file in 'w' mode
Bug #1377587 reported by
Nir Arad
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Concurrent Log Handler for Python |
New
|
Undecided
|
Unassigned |
Bug Description
shouldRollover function calls _shouldRollover() twice.
if self._shouldRol
# if some other process already did the rollover we might
# checked log.1, so we reopen the stream and check again on
# the right log file
return self._shouldRol
After the first check, if we should rollover, self._openFile will open the file again with the same mode.
However, if the mode is 'w' then the file is overwritten.
Also, because we overwritten the file, the second call to _shouldRollover will always return false.
To post a comment you must log in.
I've looked into RotatingFileHan dler.__ init__( ) and they added this:
# If rotation/rollover is wanted, it doesn't make sense to use another
# mode. If for example 'w' were specified, then if there were multiple
# runs of the calling application, the logs from previous runs would be
# lost if the 'w' is respected, because the log file would be truncated
# on each run.
if maxBytes > 0:
mode = 'a'