Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking blank if tag might coming nil or blank #3387

Merged
merged 1 commit into from
Oct 21, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion activesupport/lib/active_support/tagged_logging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'active_support/core_ext/object/blank'
require 'logger'

module ActiveSupport
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions activesupport/test/tagged_logging_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down