summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Newdigate <andrew@gitlab.com>2018-10-26 12:18:55 +0100
committerAndrew Newdigate <andrew@gitlab.com>2018-10-26 12:18:55 +0100
commit53f1de17866a24cfcfa51932f0cdbd9011046b15 (patch)
tree686f49c981ea0e64337571c7512b5fc188c125e4
parentc10c553e1db344f0cd65454373c63af0a5cb58f0 (diff)
downloadgitlab-ce-53155-structured-logs-params-array.tar.gz
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/5315553155-structured-logs-params-array
-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