aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorAlexander Staubo <alex@bengler.no>2013-01-24 22:39:19 +0100
committerAlexander Staubo <alex@bengler.no>2013-01-24 22:39:19 +0100
commit7cd0b7982520e410494e834edaa9be855d2920ad (patch)
tree0295435896a8174da08054e15e56f6a8fd99fd89 /activesupport/test
parente20c0e3a8f17d716720d248d3db5f022f7cb021a (diff)
downloadrails-7cd0b7982520e410494e834edaa9be855d2920ad.tar.gz
rails-7cd0b7982520e410494e834edaa9be855d2920ad.tar.bz2
rails-7cd0b7982520e410494e834edaa9be855d2920ad.zip
Fix TaggedLogging to allow loggers to be instantiated multiple times without having to share the stack of tags. This is accomplished by using a unique key for the thread-local tag list. Fixes #9064.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/tagged_logging_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb
index 27f629474e..03a63e94e8 100644
--- a/activesupport/test/tagged_logging_test.rb
+++ b/activesupport/test/tagged_logging_test.rb
@@ -79,6 +79,19 @@ class TaggedLoggingTest < ActiveSupport::TestCase
assert_equal "[OMG] Cool story bro\n[BCX] Funky time\n", @output.string
end
+ test "keeps each tag in their own instance" do
+ @other_output = StringIO.new
+ @other_logger = ActiveSupport::TaggedLogging.new(MyLogger.new(@other_output))
+ @logger.tagged("OMG") do
+ @other_logger.tagged("BCX") do
+ @logger.info "Cool story bro"
+ @other_logger.info "Funky time"
+ end
+ end
+ assert_equal "[OMG] Cool story bro\n", @output.string
+ assert_equal "[BCX] Funky time\n", @other_output.string
+ end
+
test "cleans up the taggings on flush" do
@logger.tagged("BCX") do
Thread.new do