Class: RailsTwirp::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/rails_twirp/log_subscriber.rb

Instance Method Summary collapse

Instance Method Details

#process_action(event) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_twirp/log_subscriber.rb', line 15

def process_action(event)
  payload = event.payload
  exception_raised(payload[:http_request], payload[:exception_object]) if payload[:exception_object]

  info do
    code = payload.fetch(:code, :internal)

    message = +"Completed #{code}"
    message << ": #{payload[:msg]}" if payload[:msg]
    message << " in #{event.duration.round}ms (Allocations: #{event.allocations})"
    message << "\n\n" if defined?(Rails.env) && Rails.env.development?

    message
  end
end

#start_processing(event) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/rails_twirp/log_subscriber.rb', line 7

def start_processing(event)
  return unless logger.info?

  payload = event.payload

  info "Processing by #{payload[:controller]}##{payload[:action]}"
end