diff options
author | FND <fnd@fnd-oda.localdomain> | 2012-03-19 10:44:20 +0100 |
---|---|---|
committer | FND <fnd@fnd-oda.localdomain> | 2012-03-19 10:49:27 +0100 |
commit | e0ee14ed2305a0b2e6ee53c5d5a98450d2f534e4 (patch) | |
tree | 51d726d54ea148da6db030bf54a3bc15af8d2573 /activesupport/test | |
parent | 24d244c1bc1a744de599df18d74c9b343fd4c9fe (diff) | |
download | rails-e0ee14ed2305a0b2e6ee53c5d5a98450d2f534e4.tar.gz rails-e0ee14ed2305a0b2e6ee53c5d5a98450d2f534e4.tar.bz2 rails-e0ee14ed2305a0b2e6ee53c5d5a98450d2f534e4.zip |
Provide access to logger instance within TaggedLogging blocks
this improves encapsulation, simplifying occurrences like the following:
Rails.logger.tagged("DEBUG") { Rails.logger.debug(msg) }
... by removing the need to rely on (i.e. repeat) outer variables:
Rails.logger.tagged("DEBUG") { |logger| logger.debug(msg) }
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/tagged_logging_test.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb index dd4ae319e5..0751c2469e 100644 --- a/activesupport/test/tagged_logging_test.rb +++ b/activesupport/test/tagged_logging_test.rb @@ -18,7 +18,7 @@ class TaggedLoggingTest < ActiveSupport::TestCase @logger.tagged("BCX") { @logger.info "Funky time" } assert_equal "[BCX] Funky time\n", @output.string end - + test "tagged twice" do @logger.tagged("BCX") { @logger.tagged("Jason") { @logger.info "Funky time" } } assert_equal "[BCX] [Jason] Funky time\n", @output.string @@ -29,6 +29,11 @@ class TaggedLoggingTest < ActiveSupport::TestCase assert_equal "[BCX] [Jason] [New] Funky time\n", @output.string end + test "provides access to the logger instance" do + @logger.tagged("BCX") { |logger| logger.info "Funky time" } + assert_equal "[BCX] 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 |