summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Newdigate <andrew@gitlab.com>2018-10-29 13:44:09 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-10-29 13:44:09 +0000
commit9a25cfc80b21b8f0d43309c0c3f3fe674a6c1e7f (patch)
tree0e390743c7395a1f84a625ed6f20c3e1979096b4 /lib
parentfb8e9729595af0bcd6698174c4632eeee25d28d7 (diff)
downloadgitlab-ce-9a25cfc80b21b8f0d43309c0c3f3fe674a6c1e7f.tar.gz
Fix open-ended params for api_json.log
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb b/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
index 0014ce2689b..41004408dec 100644
--- a/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
+++ b/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
@@ -6,7 +6,7 @@ module Gitlab
def call(severity, datetime, _, data)
time = data.delete :time
- data[:params] = utf8_encode_values(data[:params]) if data.has_key?(:params)
+ data[:params] = process_params(data)
attributes = {
time: datetime.utc.iso8601(3),
@@ -20,6 +20,14 @@ module Gitlab
private
+ def process_params(data)
+ return [] unless data.has_key?(:params)
+
+ data[:params]
+ .each_pair
+ .map { |k, v| { key: k, value: utf8_encode_values(v) } }
+ end
+
def utf8_encode_values(data)
case data
when Hash