Class: Logging::Layouts::Parseable
- Inherits:
-
Logging::Layout
- Object
- Logging::Layout
- Logging::Layouts::Parseable
- Defined in:
- lib/napa/logger/parseable.rb
Instance Method Summary collapse
-
#format_obj(obj) ⇒ Object
Public: Take a given object and convert it into a format suitable for inclusion as a log message.
Instance Method Details
#format_obj(obj) ⇒ Object
Public: Take a given object and convert it into a format suitable for inclusion as a log message. The conversion allows the object to be more easily expressed in YAML or JSON form.
If the object is an Exception, then this method will return a Hash containing the exception class name, message, and backtrace (if any).
If the object is a string, wrap it in a hash.
obj - The Object to format
Returns the formatted Object.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/napa/logger/parseable.rb', line 20 def format_obj(obj) case obj when Exception h = { class: obj.class.name, message: obj. } h[:backtrace] = obj.backtrace if @backtrace && !obj.backtrace.nil? h when Time iso8601_format(obj) when String { text: obj } else obj end end |