aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/tagged_logging_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2012-09-26 10:52:19 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2012-09-26 11:17:02 -0700
commit107fd8788f92da53232e87a220d6f4329c8f2b13 (patch)
tree7a013707819687f628a0150f31725c1a2016e38f /activesupport/test/tagged_logging_test.rb
parent8156178894dc6c57aca50a4d5f6c9398beb5f3e0 (diff)
downloadrails-107fd8788f92da53232e87a220d6f4329c8f2b13.tar.gz
rails-107fd8788f92da53232e87a220d6f4329c8f2b13.tar.bz2
rails-107fd8788f92da53232e87a220d6f4329c8f2b13.zip
Allow wrapping a logger that hasn't set a formatter. Default to our SimpleFormatter. Otherwise we try extending nil with the tagging API.
Diffstat (limited to 'activesupport/test/tagged_logging_test.rb')
-rw-r--r--activesupport/test/tagged_logging_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb
index fa045baa28..27f629474e 100644
--- a/activesupport/test/tagged_logging_test.rb
+++ b/activesupport/test/tagged_logging_test.rb
@@ -14,6 +14,14 @@ class TaggedLoggingTest < ActiveSupport::TestCase
@logger = ActiveSupport::TaggedLogging.new(MyLogger.new(@output))
end
+ test 'sets logger.formatter if missing and extends it with a tagging API' do
+ logger = Logger.new(StringIO.new)
+ assert_nil logger.formatter
+ ActiveSupport::TaggedLogging.new(logger)
+ assert_not_nil logger.formatter
+ assert logger.formatter.respond_to?(:tagged)
+ end
+
test "tagged once" do
@logger.tagged("BCX") { @logger.info "Funky time" }
assert_equal "[BCX] Funky time\n", @output.string