diff options
author | José Valim <jose.valim@gmail.com> | 2011-10-21 03:46:13 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-10-21 03:46:13 -0700 |
commit | e2aaae16292640f2314be205d7782f6eaf2b1cf5 (patch) | |
tree | 73b041f522e473249d34b3f1b8ba8a9edfa834da | |
parent | af1b5c54cfb74caddd6ffab171d26da9a5c885d1 (diff) | |
parent | c495cbcda94bec7a49a88631fc575cc04bde8e88 (diff) | |
download | rails-e2aaae16292640f2314be205d7782f6eaf2b1cf5.tar.gz rails-e2aaae16292640f2314be205d7782f6eaf2b1cf5.tar.bz2 rails-e2aaae16292640f2314be205d7782f6eaf2b1cf5.zip |
Merge pull request #3387 from arunagw/tagged_log_nil
Checking blank if tag might coming nil or blank
-rw-r--r-- | activesupport/lib/active_support/tagged_logging.rb | 3 | ||||
-rw-r--r-- | activesupport/test/tagged_logging_test.rb | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/tagged_logging.rb b/activesupport/lib/active_support/tagged_logging.rb index aff416a9eb..a59fc26d5d 100644 --- a/activesupport/lib/active_support/tagged_logging.rb +++ b/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 @@ module ActiveSupport 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 diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb index b12b12f32c..17c4214dfc 100644 --- a/activesupport/test/tagged_logging_test.rb +++ b/activesupport/test/tagged_logging_test.rb @@ -29,6 +29,11 @@ class TaggedLoggingTest < ActiveSupport::TestCase 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 |