aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/CHANGELOG.md4
-rw-r--r--activesupport/lib/active_support/tagged_logging.rb9
-rw-r--r--activesupport/test/tagged_logging_test.rb12
3 files changed, 23 insertions, 2 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index d612c644af..eaebe49070 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -15,6 +15,10 @@
Fixes #9678.
*Andrew White*
+
+* Fix `ActiveSupport::TaggedLogging` incorrectly providing program name the same as log message even when block is not provided.
+
+ *Carson Reinke*
## Rails 3.2.13 (Mar 18, 2013) ##
diff --git a/activesupport/lib/active_support/tagged_logging.rb b/activesupport/lib/active_support/tagged_logging.rb
index 7e7f7ecfb2..6fff3bc0d4 100644
--- a/activesupport/lib/active_support/tagged_logging.rb
+++ b/activesupport/lib/active_support/tagged_logging.rb
@@ -44,7 +44,14 @@ module ActiveSupport
deprecate :silence
def add(severity, message = nil, progname = nil, &block)
- message = (block_given? ? block.call : progname) if message.nil?
+ if message.nil?
+ if block_given?
+ message = block.call
+ else
+ message = progname
+ progname = nil #No instance variable for this like Logger
+ end
+ end
@logger.add(severity, "#{tags_text}#{message}", progname)
end
diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb
index 7253eb1222..91c311ba16 100644
--- a/activesupport/test/tagged_logging_test.rb
+++ b/activesupport/test/tagged_logging_test.rb
@@ -4,14 +4,24 @@ require 'active_support/tagged_logging'
class TaggedLoggingTest < ActiveSupport::TestCase
class MyLogger < ::Logger
+ attr_accessor :last_message
+ attr_accessor :last_progname
+
def flush(*)
info "[FLUSHED]"
end
+
+ def add(severity, message = nil, progname = nil, &block)
+ @last_message = message
+ @last_progname = progname
+ super(severity, message, progname, &block)
+ end
end
setup do
@output = StringIO.new
- @logger = ActiveSupport::TaggedLogging.new(MyLogger.new(@output))
+ @my_logger = MyLogger.new(@output)
+ @logger = ActiveSupport::TaggedLogging.new(@my_logger)
end
test "tagged once" do