Skip to content
This repository
Browse code

Don't use default separator

When the default separator is set logger will create incorrect output
  • Loading branch information...
commit dc97a9a9ddc98ff65cc4826ac96c8594fec7b8f0 1 parent 58ccc9f
Piotr Niełacny LTe authored
2  activesupport/lib/active_support/tagged_logging.rb
@@ -31,7 +31,7 @@ def current_tags
31 31 def tags_text
32 32 tags = current_tags
33 33 if tags.any?
34   - tags.collect { |tag| "[#{tag}] " }.join
  34 + tags.collect { |tag| "[#{tag}] " }.join('')
35 35 end
36 36 end
37 37 end
15 activesupport/test/tagged_logging_test.rb
@@ -10,8 +10,13 @@ def flush(*)
10 10 end
11 11
12 12 setup do
13   - @output = StringIO.new
14   - @logger = ActiveSupport::TaggedLogging.new(MyLogger.new(@output))
  13 + @output = StringIO.new
  14 + @logger = ActiveSupport::TaggedLogging.new(MyLogger.new(@output))
  15 + @separator = $,
  16 + end
  17 +
  18 + after do
  19 + $, = @separator
15 20 end
16 21
17 22 test "tagged once" do
@@ -69,4 +74,10 @@ def flush(*)
69 74
70 75 assert_equal "[BCX] [Jason] Funky time\n[BCX] Junky time!\n", @output.string
71 76 end
  77 +
  78 + test "using the correct separator" do
  79 + $, = "_"
  80 + @logger.tagged("BCX", "BDX") { @logger.info "Funky time" }
  81 + assert_equal "[BCX] [BDX] Funky time\n", @output.string
  82 + end
72 83 end

0 comments on commit dc97a9a

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