Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Incorrectly providing program name the same as log message even when …

…block is not provided.
  • Loading branch information...
commit 4265f1bccbabc293e87cc8433a5573dcb7fa5a60 1 parent 9a8f593
@carsonreinke carsonreinke authored
View
4 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) ##
View
9 activesupport/lib/active_support/tagged_logging.rb
@@ -44,7 +44,14 @@ def silence(temporary_level = Logger::ERROR, &block)
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
View
12 activesupport/test/tagged_logging_test.rb
@@ -4,14 +4,24 @@
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
Please sign in to comment.
Something went wrong with that request. Please try again.