diff options
author | Stan Hu <stanhu@gmail.com> | 2018-03-20 16:29:24 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-03-20 16:38:36 -0700 |
commit | 467aa65e115a7d7350f41c4936833cf0e6837807 (patch) | |
tree | bfe515dabc9526b3ed3aa391308a45d4e4eeb994 | |
parent | 398f13f39a0ce51c9ca3f223e87df88db822a396 (diff) | |
download | gitlab-ce-467aa65e115a7d7350f41c4936833cf0e6837807.tar.gz |
Strip any query string parameters from Location headers from lograge
Port of https://github.com/roidrage/lograge/pull/241
-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") |