diff options
author | Robert Speicher <robert@gitlab.com> | 2018-03-21 00:32:39 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2018-03-21 19:13:00 -0500 |
commit | e9613d4a760689d1b55d0735a08b159c1dc5b378 (patch) | |
tree | 89cb97bb5f5367ff5aa744cef73ba8334e595fa3 | |
parent | 09fdf9ee6a08c798cd25a130ea1817bc4afe6f58 (diff) | |
download | gitlab-ce-e9613d4a760689d1b55d0735a08b159c1dc5b378.tar.gz |
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
-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") |