class DispatchRider::Logging::TextFormatter
Public Instance Methods
format(data)
click to toggle source
# File lib/dispatch-rider/logging/text_formatter.rb, line 7 def format(data) case data[:phase] when :complete "Completed execution of: #{message_info_fragment(data)} in #{format_duration(data[:duration])} seconds" when :fail "Failed execution of: #{exception_info_fragment(data)}" when :start "Starting execution of: #{message_info_fragment(data)}" when :success "Succeeded execution of: #{message_info_fragment(data)}" when :stop "Got stop #{data[:reason] ? '(' + data[:reason] + ')' : ''} while executing: #{message_info_fragment(data)}" when :error_handler_fail "Failed error handling of: #{exception_info_fragment(data)}" else raise ArgumentError, "Invalid phase : #{data[:phase].inspect}" end end
Private Instance Methods
exception_info_fragment(data)
click to toggle source
# File lib/dispatch-rider/logging/text_formatter.rb, line 32 def exception_info_fragment(data) "(#{data[:guid]}): #{data[:subject]} with #{data[:exception][:class]}: #{data[:exception][:message]}" end
format_duration(duration)
click to toggle source
# File lib/dispatch-rider/logging/text_formatter.rb, line 43 def format_duration(duration) '%.2f' % [duration] end
message_info_arguments(body)
click to toggle source
# File lib/dispatch-rider/logging/text_formatter.rb, line 36 def message_info_arguments(body) body.dup.tap do |m| m.delete('guid') m.delete('object_id') end end
message_info_fragment(data)
click to toggle source
# File lib/dispatch-rider/logging/text_formatter.rb, line 28 def message_info_fragment(data) "(#{data[:guid]}): #{data[:subject]} : #{message_info_arguments(data[:body]).inspect}" end