diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-08 00:06:57 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-08 00:06:57 +0000 |
commit | 8fc170a34eff0190533b669b3e9f6b6aba42e48c (patch) | |
tree | 3b795f4ae3b1773e061f21a88962f5456d3457fa /lib/logger.rb | |
parent | d94ea30a576136d93b122b6eb69971b18be927d5 (diff) |
logger: fix monthly log rotate with DST
* lib/logger.rb (Logger::Period#next_rotate_time): fix monthly log
rotate when DST is applied during a month of 31 days.
[Fix GH-1458]
With DST the month of october can actually last more than 31 days.
It can last 31 days plus 1 hour. So during october, `t` used to be
equal to "2016-10-31 23:00:00" instead of "2016-11-01 00:00:00".
This was then normalized to "2016-10-01 00:00:00" which lead every
single line of log during october to rotate the log file.
This fix ensure that next_rotate_time(now, 'monthly') always return
the first day of next month in every situation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/logger.rb')
-rw-r--r-- | lib/logger.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/logger.rb b/lib/logger.rb index a81b7cc182..54fde9517d 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -629,8 +629,8 @@ private when 'weekly' t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday) when 'monthly' - t = Time.mktime(now.year, now.month, 1) + SiD * 31 - return Time.mktime(t.year, t.month, 1) if t.mday > 1 + t = Time.mktime(now.year, now.month, 1) + SiD * 32 + return Time.mktime(t.year, t.month, 1) else return now end |