class LogStasher::ActionView::LogSubscriber

Public Instance Methods

logger() click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 18
def logger
  LogStasher.logger
end
render_collection(event)
Alias for: render_template
render_partial(event)
Alias for: render_template
render_template(event) click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 12
def render_template(event)
  logstash_event(event)
end
Also aliased as: render_partial, render_collection

Private Instance Methods

event_data(event) click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 51
def event_data(event)
  {
    name: event.name,
    transaction_id: event.transaction_id
  }
end
extract_data(data) click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 39
def extract_data(data)
  { identifier: from_rails_root(data[:identifier]) }
end
logstash_event(event) click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 24
def logstash_event(event)
  data = event.payload

  data.merge! event_data(event)
  data.merge! runtimes(event)
  data.merge! extract_data(data)
  data.merge! request_context
  data.merge! LogStasher.store
  data.merge! extract_custom_fields(data)

  tags = []
  tags.push('exception') if data[:exception]
  logger << "#{LogStasher.build_logstash_event(data, tags).to_json}\n"
end
request_context() click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 43
def request_context
  LogStasher.request_context
end
runtimes(event) click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 58
def runtimes(event)
  {
    duration: event.duration
  }.each_with_object({}) do |(name, runtime), runtimes|
    runtimes[name] = runtime.to_f.round(2) if runtime
  end
end
store() click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 47
def store
  LogStasher.store
end