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
上级 2a34e082
*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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册