Without binmode strings with incompatible encoding can't be written in
the file. This is very common in applications that log user provided
parameters.
We need to allow changing the binnary mode because right now it is impossible to use
the built-in log rotation feature when you provide a File object to the
LogDevice, and if you provide a filename you can't have binmode.
https://github.com/ruby/logger/commit/9114b3ac7e
* test/logger/test_logdevice.rb: revert r60999 because it was caused by not
committed changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/logger/test_logdevice.rb (test_shifting_{age,period_suffix}): give a
chance to determine to rotate the log or not.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Make write methods of IO-like objects accept multiple arguments,
as well as IO#write.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Because progname was memoized with ||= a logger call that involved
outputting false would be nil. Example code:
logger = Logger.new(STDOUT)
logger.info(false) # => nil
Perform an explicit nil check instead of ||= so that false will be output.
patched by Gavin Miller <gavingmiller@gmail.com> [Fix GH-1667]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/logger.rb (Logger::LogDevice#initialize): calculate next
rotate time based on the mtime of the last existing file.
[ruby-dev:49881] [Bug #12948]
Author: Tsukasa Oishi <tsukasa.oishi@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/logger/test_logger.rb (test_datetime_format): suppress
warning when strftime called with empty format string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
too many shifting. the last shifting created logs named as `*.3`, and
they were never unlinked.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/logger/test_logdevice.rb: use assert_predicate,
assert_not_predicate, and assert_file instead of bare assert.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
When you change this to true, you may need to add more tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/logger.rb (Logger::Period#previous_period_end): as weekly
rotation shifts the log file on Sundays, the end date of the
previous period should be Saturdays. fix r45072.
[ruby-dev:49314] [Bug #11622]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/logger.rb (Logger::Period#next_rotate_time): get rid of
adding to mday not to exceed the days of the month.
[ruby-core:71185] [Bug #11620]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/logger/test_logdevice.rb (test_shifting_midnight): do not
set mtime to get rid of an error on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/logger/test_logdevice.rb (test_shifting_dst_change): test
only on platforms where timezone is supported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/logger.rb (Logger::LogDevice#check_shift_log): compare the
current time with the time for the next rotation to fix rotation
miss when date changed between the comparison and log writing.
based on the patch by megayu <yuhg2310 AT gmail.com>.
[Fixes GH-539]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e