Class: Lumberjack::EcsDevice::MessageExceptionFormatter
- Inherits:
-
Object
- Object
- Lumberjack::EcsDevice::MessageExceptionFormatter
- Includes:
- ExceptionHash
- Defined in:
- lib/lumberjack_ecs_device.rb
Overview
Formatter to format a messge as an error if it is an exception.
Instance Method Summary collapse
- #call(object) ⇒ Object
-
#initialize(device = nil) ⇒ MessageExceptionFormatter
constructor
A new instance of MessageExceptionFormatter.
Constructor Details
#initialize(device = nil) ⇒ MessageExceptionFormatter
Returns a new instance of MessageExceptionFormatter.
30 31 32 |
# File 'lib/lumberjack_ecs_device.rb', line 30 def initialize(device = nil) @device = device end |
Instance Method Details
#call(object) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lumberjack_ecs_device.rb', line 34 def call(object) if object.is_a?(Exception) { "message" => object.inspect, "error" => exception_hash(object, @device) } elsif object.is_a?(Hash) {"message" => object} elsif object.nil? {"message" => nil} else = object.to_s = @device. if && .length > = [0, ] end {"message" => } end end |