aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/kernel/reporting.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-04 19:39:26 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-04 19:39:26 +0000
commiteb01d35109897162a48ff5219dcd97f35328168c (patch)
tree8ce1d54d29dff34550b33bc5b6696945d8876ca1 /activesupport/lib/active_support/core_ext/kernel/reporting.rb
parentc0fb67c0f88bb81f525185a8dfceec6fb7cb298e (diff)
downloadrails-eb01d35109897162a48ff5219dcd97f35328168c.tar.gz
rails-eb01d35109897162a48ff5219dcd97f35328168c.tar.bz2
rails-eb01d35109897162a48ff5219dcd97f35328168c.zip
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
Diffstat (limited to 'activesupport/lib/active_support/core_ext/kernel/reporting.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/kernel/reporting.rb23
1 files changed, 14 insertions, 9 deletions
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)