lib/logstasher/log_subscriber.rb in md-logstasher-1.4.1 vs lib/logstasher/log_subscriber.rb in md-logstasher-1.5.0

- old
+ new

@@ -26,13 +26,11 @@ fields.merge! location fields.merge! extract_exception(payload) fields.merge! extract_parameters(payload) fields.merge! appended_fields - event = LogStash::Event.new(fields.merge('tags' => tags)) - - LogStasher.logger << event.to_json + "\n" + LogStasher.log_as_json(fields.merge('tags' => tags), :as_logstash_event => true) end def redirect_to(event) Thread.current[:logstasher_context][:location] = event.payload[:location] end @@ -49,22 +47,19 @@ def controller Thread.current[:logstasher_context][:controller] end def extract_request(payload) - result = { + { :action => payload[:action], :controller => payload[:controller], :format => extract_format(payload), :ip => request.remote_ip, :request_id => request.env["action_dispatch.request_id"], :method => payload[:method], :path => extract_path(payload), :route => "#{payload[:controller]}##{payload[:action]}" } - metadata = ::LogStasher.metadata - result.merge!(:metadata => metadata) unless metadata&.empty? - result end # Monkey patching to enable exception logging def extract_exception(payload) if payload[:exception]