Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Don't use default separator in tagged logger #7084

Merged
merged 1 commit into from

2 participants

@LTe

When the default separator is set logger will create incorrect output

$, = "_"
@logger.tagged("BCX", "BDX") { @logger.info "Funky time" }
# => [BCX] _[BDX] Funky time
@LTe LTe Don't use default separator
When the default separator is set logger will create incorrect output
dc97a9a
@josevalim josevalim merged commit c08f30f into rails:master
@tenderlove tenderlove referenced this pull request from a commit
@tenderlove tenderlove Revert "Merge pull request #7084 from LTe/logger_default_separator"
This reverts commit c08f30f, reversing
changes made to e243a8a.
e482100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 18, 2012
  1. @LTe

    Don't use default separator

    LTe authored
    When the default separator is set logger will create incorrect output
This page is out of date. Refresh to see the latest.
View
2  activesupport/lib/active_support/tagged_logging.rb
@@ -31,7 +31,7 @@ def current_tags
def tags_text
tags = current_tags
if tags.any?
- tags.collect { |tag| "[#{tag}] " }.join
+ tags.collect { |tag| "[#{tag}] " }.join('')
end
end
end
View
15 activesupport/test/tagged_logging_test.rb
@@ -10,8 +10,13 @@ def flush(*)
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 @@ def flush(*)
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
Something went wrong with that request. Please try again.