Permalink
Browse files

Added call to inspect on non-string classes for the logger (closes #8533

) [codahale]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7565 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 2a34e08 commit 05f173e2c2607e38cc4f86d53fbba8c832082208 @dhh dhh committed Sep 22, 2007
View
@@ -1,5 +1,7 @@
*SVN*
+* Added call to inspect on non-string classes for the logger #8533 [codahale]
+
* Deprecation: remove deprecated :mday option from Time, Date, and DateTime#change. [Jeremy Kemper]
* Fix JSON decoder with nested quotes and commas. #9579 [zdennis]
@@ -93,7 +93,7 @@ def msg2str(msg)
class SimpleFormatter < Logger::Formatter
# This method is invoked when a log event occurs
def call(severity, timestamp, progname, msg)
- "#{msg}\n"
+ "#{String === msg ? msg : msg.inspect}\n"
end
end
@@ -48,4 +48,10 @@ def test_datetime_format
assert_equal "%Y-%m-%d", @logger.datetime_format
assert_match(/D, \[\d\d\d\d-\d\d-\d\d#\d+\] DEBUG -- : debug/, @out.string)
end
+
+ def test_nonstring_formatting
+ an_object = [1, 2, 3, 4, 5]
+ @logger.debug an_object
+ assert_equal("#{an_object.inspect}\n", @out.string)
+ end
end

0 comments on commit 05f173e

Please sign in to comment.