Fixes the TimeBasedRollingPolicy.cpp
Joseph Southwell <joseph <at> southwell.org>
2012-01-23 15:44:42 GMT
I made a couple of changes to the TimeBasedRollingPolicy and I was wondering if I could get them added
upstream? I have never done this before so I have no idea how this process should work. Any guidance?
They allow it to handle rolling log files with multiple clients writing to the file. It is not perfect, there
is still at least one way it can break but it works most of the time without a hitch and that one way happened
every time before. first writer renames file, second renames file again overwrites first renamed file. I
fixed that by putting a check for File.exists() in FileRenameAction. Execute now returns false when the
target file already exists. obviously that exists, rename bit needs to be made atomic for this to be
perfect but this is a good start.
I also added an append variable to TimeBasedRollingPolicy to save the state of append from the initialize
call so that when rollover returns the rollover description it can return the correct value for append
since with multiple writers writing to the file it is necessary not to loose the append setting.
I also added a check for file modification time in initialize and set lastFileName based on that
modification time so that it could rollover files that are from yesterday. I wanted rollover to work even
if nothing is running when the rollover was supposed to happen.
I would like to avoid maintaining a separate branch so how do I get this put in?