diff options
author | Robert Speicher <robert@gitlab.com> | 2018-03-21 03:32:39 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-03-21 03:32:39 +0300 |
commit | 2025f361e7520e00962f6964aa77c4f4e6c3d56b (patch) | |
tree | 0f0e7e40bfb357447c0150cba6b3bc854acaf6e3 /config | |
parent | 7887835561c9b5b74921fa1842336adafad07c20 (diff) | |
parent | 467aa65e115a7d7350f41c4936833cf0e6837807 (diff) |
Merge branch 'sh-lograge-strip-location-header' into 'master'
Strip any query string parameters from Location headers from lograge
See merge request gitlab-org/gitlab-ce!17895
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/lograge.rb | 18 |
1 files changed, 18 insertions, 0 deletions
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") |