Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3387 from arunagw/tagged_log_nil

Checking blank if tag might coming nil or blank
  • Loading branch information...
commit e2aaae16292640f2314be205d7782f6eaf2b1cf5 2 parents af1b5c5 + c495cbc
@josevalim josevalim authored
View
3  activesupport/lib/active_support/tagged_logging.rb
@@ -1,3 +1,4 @@
+require 'active_support/core_ext/object/blank'
require 'logger'
module ActiveSupport
@@ -18,7 +19,7 @@ def initialize(logger)
def tagged(*new_tags)
tags = current_tags
- new_tags = Array.wrap(new_tags).flatten
+ new_tags = Array.wrap(new_tags).flatten.reject(&:blank?)
tags.concat new_tags
yield
ensure
View
5 activesupport/test/tagged_logging_test.rb
@@ -29,6 +29,11 @@ def flush(*)
assert_equal "[BCX] [Jason] [New] Funky time\n", @output.string
end
+ test "tagged once with blank and nil" do
+ @logger.tagged(nil, "", "New") { @logger.info "Funky time" }
+ assert_equal "[New] Funky time\n", @output.string
+ end
+
test "keeps each tag in their own thread" do
@logger.tagged("BCX") do
Thread.new do
Please sign in to comment.
Something went wrong with that request. Please try again.