Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Merge pull request #7084 from LTe/logger_default_separator"

This reverts commit c08f30f, reversing
changes made to e243a8a.
  • Loading branch information...
commit e482100d6ed022d00ba31c6c4377f6f947173337 1 parent fe5b943
@tenderlove tenderlove authored
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,13 +10,8 @@ def flush(*)
end
setup do
- @output = StringIO.new
- @logger = ActiveSupport::TaggedLogging.new(MyLogger.new(@output))
- @separator = $,
- end
-
- after do
- $, = @separator
+ @output = StringIO.new
+ @logger = ActiveSupport::TaggedLogging.new(MyLogger.new(@output))
end
test "tagged once" do
@@ -74,10 +69,4 @@ 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

5 comments on commit e482100

@rafaelfranca

Reason?

@steveklabnik
Collaborator

I wasn't involved in this discussion, but $, should absolutely be respected. We're not making a custom Ruby for Rails...

@tenderlove
Owner

If you modify a global variable, it modifies the behavior of the program, globally.

People who never set the global variable would not notice the "fix" in the previous commit. People who depended on the global variable would have broken code. Best case: nobody would notice the commit, worst case: we broke someone's code.

@tenderlove
Owner

TBH, a better argument to not use the $, (in this case), would be that the current code ends up with a blank space at the end of the string. It would be better if the code was changed to tags.collect { |tag| "[#{tag}]" }.join ' '.

@rafaelfranca

seems good. Thank you to explain.

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