-
-
Notifications
You must be signed in to change notification settings - Fork 938
Redirecting STDERR not working as expected #1082
Copy link
Copy link
Closed
Labels
Milestone
Description
Trying to redirect STDERR to log, $stderr.puts works, as does warn, but raised errors never make it to the log.
log = File.new('/home/my_user/test_log.log', "w")
$stderr.reopen log
$stderr.puts "writing to log!"
warn "warning!"
require 'some_broken_thing'
log contents in MRI (2.0.0-p0):
/path/to/ruby/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- some_broken_thing (LoadError)
from /path/to/ruby/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from test.rb:5:in `<main>'
writing to log!
warning!
log contents in jruby (1.7.4):
writing to log!
warning!
When I call $stderr.reopen, the error output from the broken require doesn't show up in the console, which is good, but it also never shows up in the file, which isn't so good.
Reactions are currently unavailable