[ruby/logger] Fix log rotation inter-process lock failed.
Issue only occurs in JRuby 9.3.0.0 and Windows and the full console output is: log rotation inter-process lock failed. D:\log.txt -> D:\log.txt.0: The process cannot access the file because it is being used by another process. log writing failed. closed stream log writing failed. closed stream ... https://github.com/ruby/logger/commit/19fc734638
This commit is contained in:
parent
d3d888b986
commit
99d02caed3
@ -11,6 +11,7 @@
|
|||||||
# A simple system for logging messages. See Logger for more documentation.
|
# A simple system for logging messages. See Logger for more documentation.
|
||||||
|
|
||||||
require 'monitor'
|
require 'monitor'
|
||||||
|
require 'rbconfig'
|
||||||
|
|
||||||
require_relative 'logger/version'
|
require_relative 'logger/version'
|
||||||
require_relative 'logger/formatter'
|
require_relative 'logger/formatter'
|
||||||
|
@ -135,7 +135,7 @@ class Logger
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
|
if /mswin|mingw|cygwin/ =~ RbConfig::CONFIG['host_os']
|
||||||
def lock_shift_log
|
def lock_shift_log
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
|
@ -435,6 +435,7 @@ class TestLogDevice < Test::Unit::TestCase
|
|||||||
|
|
||||||
logdev1.write(message)
|
logdev1.write(message)
|
||||||
assert_file.identical?(log, logdev1.dev)
|
assert_file.identical?(log, logdev1.dev)
|
||||||
|
# NOTE: below assertion fails in JRuby 9.3 and TruffleRuby
|
||||||
assert_file.identical?(log + ".0", logdev2.dev)
|
assert_file.identical?(log + ".0", logdev2.dev)
|
||||||
|
|
||||||
logdev2.write(message)
|
logdev2.write(message)
|
||||||
@ -451,7 +452,7 @@ class TestLogDevice < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
logdev0.close
|
logdev0.close
|
||||||
end unless /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
|
end unless /mswin|mingw|cygwin/ =~ RbConfig::CONFIG['host_os']
|
||||||
|
|
||||||
def test_shifting_midnight
|
def test_shifting_midnight
|
||||||
Dir.mktmpdir do |tmpdir|
|
Dir.mktmpdir do |tmpdir|
|
||||||
|
@ -254,7 +254,7 @@ module Test
|
|||||||
line ||= loc.lineno
|
line ||= loc.lineno
|
||||||
end
|
end
|
||||||
capture_stdout = true
|
capture_stdout = true
|
||||||
unless /mswin|mingw/ =~ RUBY_PLATFORM
|
unless /mswin|mingw/ =~ RbConfig::CONFIG['host_os']
|
||||||
capture_stdout = false
|
capture_stdout = false
|
||||||
opt[:out] = Test::Unit::Runner.output if defined?(Test::Unit::Runner)
|
opt[:out] = Test::Unit::Runner.output if defined?(Test::Unit::Runner)
|
||||||
res_p, res_c = IO.pipe
|
res_p, res_c = IO.pipe
|
||||||
|
Loading…
x
Reference in New Issue
Block a user