Strip any query string parameters from Location headers from lograge

Port of https://github.com/roidrage/lograge/pull/241
This commit is contained in:
Stan Hu 2018-03-20 16:29:24 -07:00
parent 398f13f39a
commit 467aa65e11
1 changed files with 18 additions and 0 deletions

View File

@ -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")