From 467aa65e115a7d7350f41c4936833cf0e6837807 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 20 Mar 2018 16:29:24 -0700 Subject: Strip any query string parameters from Location headers from lograge Port of https://github.com/roidrage/lograge/pull/241 --- config/initializers/lograge.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'config') diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb index 114c1cb512f..49fdd23064c 100644 --- a/config/initializers/lograge.rb +++ b/config/initializers/lograge.rb @@ -1,3 +1,21 @@ +# Monkey patch lograge until https://github.com/roidrage/lograge/pull/241 is released +module Lograge + class RequestLogSubscriber < ActiveSupport::LogSubscriber + def strip_query_string(path) + index = path.index('?') + index ? path[0, index] : path + end + + def extract_location + location = Thread.current[:lograge_location] + return {} unless location + + Thread.current[:lograge_location] = nil + { location: strip_query_string(location) } + end + end +end + # Only use Lograge for Rails unless Sidekiq.server? filename = File.join(Rails.root, 'log', "#{Rails.env}_json.log") -- cgit v1.2.3