ruby/ruby — pull request #539 by megayu (2014-02-19 06:00:00+00:00)
Title: Fixup sometimes logger fails on age log rotation

Age log rotation is very useful, like `Logger.new log_name, 'daily'`, that should make every day has their own log file, but right now that's not for sure. Sometimes logger will continues to write in old log file after age rotation.

Current implements compare the modify time of the log file and the end time of previous period for checking whether should shift the log file, there is one case will cause the problem, if the comparing happening in almost midnight, like *2014-01-02 23:59:59.999*, that's larger than *2014-01-01 23:59:59*, no need to shift at that time, and the real writing to disk will happen the next day, like *2014-01-03 00:00:00.121*, so at the next log event, the modify time will still be larger than *2014-01-02 23:59:59*.

In my real situation, if there is some events in *23:59:59*, it will never shift the log file.

So i change the implements of `check_shift_log`, import a new instance variable in `LogDevice` class, named `@next_rotate_time`, it will hold the start time of next period, for example, current day is *2014-02-19*, the value will be *2014-02-20 00:00:00.000*, in `check_shift_log`, if the current time is large than that value, will shift the log file and update `@next_rotate_time`, in this case, it will be *2014-02-21 00:00:00.000*.

That should fix the problem.