Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
@@ -33,13 +33,14 @@ def silence(temporary_level = Logger::ERROR, &block)
33 33 deprecate :silence
34 34
35 35 def add(severity, message = nil, progname = nil, &block)
36   - @logger.add(severity, "#{tags_text}#{message}", progname, &block)
  36 + message = (block_given? ? block.call : progname) if message.nil?
  37 + @logger.add(severity, "#{tags_text}#{message}", progname)
37 38 end
38 39
39 40 %w( fatal error warn info debug unknown ).each do |severity|
40 41 eval <<-EOM, nil, __FILE__, __LINE__ + 1
41 42 def #{severity}(progname = nil, &block)
42   - add(Logger::#{severity.upcase}, progname, &block)
  43 + add(Logger::#{severity.upcase}, nil, progname, &block)
43 44 end
44 45 EOM
45 46 end
8 activesupport/test/tagged_logging_test.rb
@@ -70,4 +70,12 @@ def flush(*)
70 70 assert_nothing_raised { @logger.silence {} }
71 71 end
72 72 end
  73 +
  74 + test "calls block" do
  75 + @logger.tagged("BCX") do
  76 + @logger.info { "Funky town" }
  77 + end
  78 + assert_equal "[BCX] Funky town\n", @output.string
  79 + end
  80 +
73 81 end

0 comments on commit bd93ba5

Please sign in to comment.
Something went wrong with that request. Please try again.