From eb01d35109897162a48ff5219dcd97f35328168c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 4 Mar 2006 19:39:26 +0000 Subject: Added socket cleanup for lighttpd, both before and after [DHH] Added automatic creation of tmp/ when running script/server [DHH] Added silence_stream that'll work on both STDERR or STDOUT or any other stream and deprecated silence_stderr in the process [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3761 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../active_support/core_ext/kernel/reporting.rb | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/kernel/reporting.rb b/activesupport/lib/active_support/core_ext/kernel/reporting.rb index 232443601c..a5cec50245 100644 --- a/activesupport/lib/active_support/core_ext/kernel/reporting.rb +++ b/activesupport/lib/active_support/core_ext/kernel/reporting.rb @@ -21,20 +21,25 @@ module Kernel $VERBOSE = old_verbose end - # Silences stderr for the duration of the block. + # For compatibility + def silence_stderr #:nodoc: + silence_stream(STDERR) { yield } + end + + # Silences any stream for the duration of the block. # - # silence_stderr do - # $stderr.puts 'This will never be seen' + # silence_stream(STDOUT) do + # puts 'This will never be seen' # end # - # $stderr.puts 'But this will' - def silence_stderr - old_stderr = STDERR.dup - STDERR.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null') - STDERR.sync = true + # puts 'But this will' + def silence_stream(stream) + old_stream = stream.dup + stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null') + stream.sync = true yield ensure - STDERR.reopen(old_stderr) + stream.reopen(old_stream) end def suppress(*exception_classes) -- cgit v1.2.3