Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4793 from kennyj/fix_4760

[3-2-stable] Fix GH #4760. A Block was not evaluated.
  • Loading branch information...
commit bd93ba5b16ae7a150ea0da282fc1277677c13f49 2 parents 85c724d + 91700bf
José Valim josevalim authored
5 activesupport/lib/active_support/tagged_logging.rb
View
@@ -33,13 +33,14 @@ def silence(temporary_level = Logger::ERROR, &block)
deprecate :silence
def add(severity, message = nil, progname = nil, &block)
- @logger.add(severity, "#{tags_text}#{message}", progname, &block)
+ message = (block_given? ? block.call : progname) if message.nil?
+ @logger.add(severity, "#{tags_text}#{message}", progname)
end
%w( fatal error warn info debug unknown ).each do |severity|
eval <<-EOM, nil, __FILE__, __LINE__ + 1
def #{severity}(progname = nil, &block)
- add(Logger::#{severity.upcase}, progname, &block)
+ add(Logger::#{severity.upcase}, nil, progname, &block)
end
EOM
end
8 activesupport/test/tagged_logging_test.rb
View
@@ -70,4 +70,12 @@ def flush(*)
assert_nothing_raised { @logger.silence {} }
end
end
+
+ test "calls block" do
+ @logger.tagged("BCX") do
+ @logger.info { "Funky town" }
+ end
+ assert_equal "[BCX] Funky town\n", @output.string
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.