aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorCarson Reinke <carson@reinke.co>2013-01-10 13:36:05 -0500
committerCarson Reinke <carson@reinke.co>2013-07-01 10:11:43 -0400
commit4265f1bccbabc293e87cc8433a5573dcb7fa5a60 (patch)
tree9a47b2bb2008e2334b20f9d375f99326a70e0c12 /activesupport
parent9a8f59340b86151b183d6561a94b953371c3daf3 (diff)
downloadrails-4265f1bccbabc293e87cc8433a5573dcb7fa5a60.tar.gz
rails-4265f1bccbabc293e87cc8433a5573dcb7fa5a60.tar.bz2
rails-4265f1bccbabc293e87cc8433a5573dcb7fa5a60.zip
Incorrectly providing program name the same as log message even when block is not provided.
Diffstat (limited to 'activesupport')
-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