Class: DispatchRider::Logging::TextFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/dispatch-rider/logging/text_formatter.rb

Instance Method Summary collapse

Instance Method Details

#format(data) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dispatch-rider/logging/text_formatter.rb', line 6

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