class LogStasher::ActionView::LogSubscriber

Public Instance Methods

logger() click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 13
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 7
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 46
def event_data(event)
  {
    name: event.name,
    transaction_id: event.transaction_id,
  }
end
extract_custom_fields(data) click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 63
def extract_custom_fields(data)
  custom_fields = (!LogStasher.custom_fields.empty? && data.extract!(*LogStasher.custom_fields)) || {}
  LogStasher.custom_fields.clear
  custom_fields
end
extract_data(data) click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 34
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 19
      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! 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 38
def request_context
  LogStasher.request_context
end
runtimes(event) click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 53
def runtimes(event)
  {
    duration: event.duration,
  }.inject({}) do |runtimes, (name, runtime)|
    runtimes[name] = runtime.to_f.round(2) if runtime
    runtimes
  end

end
store() click to toggle source
# File lib/logstasher/action_view/log_subscriber.rb, line 42
def store
  LogStasher.store
end