From dc97a9a9ddc98ff65cc4826ac96c8594fec7b8f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Nie=C5=82acny?= Date: Wed, 18 Jul 2012 09:44:45 +0200 Subject: Don't use default separator When the default separator is set logger will create incorrect output --- activesupport/lib/active_support/tagged_logging.rb | 2 +- activesupport/test/tagged_logging_test.rb | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/tagged_logging.rb b/activesupport/lib/active_support/tagged_logging.rb index 5e080df518..974c42ebba 100644 --- a/activesupport/lib/active_support/tagged_logging.rb +++ b/activesupport/lib/active_support/tagged_logging.rb @@ -31,7 +31,7 @@ module ActiveSupport def tags_text tags = current_tags if tags.any? - tags.collect { |tag| "[#{tag}] " }.join + tags.collect { |tag| "[#{tag}] " }.join('') end end end diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb index 0751c2469e..732a28c56f 100644 --- a/activesupport/test/tagged_logging_test.rb +++ b/activesupport/test/tagged_logging_test.rb @@ -10,8 +10,13 @@ class TaggedLoggingTest < ActiveSupport::TestCase end setup do - @output = StringIO.new - @logger = ActiveSupport::TaggedLogging.new(MyLogger.new(@output)) + @output = StringIO.new + @logger = ActiveSupport::TaggedLogging.new(MyLogger.new(@output)) + @separator = $, + end + + after do + $, = @separator end test "tagged once" do @@ -69,4 +74,10 @@ class TaggedLoggingTest < ActiveSupport::TestCase assert_equal "[BCX] [Jason] Funky time\n[BCX] Junky time!\n", @output.string end + + test "using the correct separator" do + $, = "_" + @logger.tagged("BCX", "BDX") { @logger.info "Funky time" } + assert_equal "[BCX] [BDX] Funky time\n", @output.string + end end -- cgit v1.2.3