Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-28 00:09:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-28 00:09:17 +0300
commitc77fda905a8619b756163c10a75171dc9cfe7084 (patch)
treeffa93b37bfe4b99ba0b8584c7a0bd1a4cd19772a /lib/gitlab/grape_logging
parente0fa0638a422c3e20d4423c9bb69d79afc9c7d3d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/grape_logging')
-rw-r--r--lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb b/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
index 1eb1e1b783b..045a341f2ed 100644
--- a/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
+++ b/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
@@ -6,6 +6,8 @@ module Gitlab
class LogrageWithTimestamp
include Gitlab::EncodingHelper
+ EMPTY_ARRAY = [].freeze
+
def call(severity, datetime, _, data)
time = data.delete :time
data[:params] = process_params(data)
@@ -16,30 +18,27 @@ module Gitlab
duration: time[:total],
db: time[:db],
view: time[:view]
- }.merge(data)
- ::Lograge.formatter.call(attributes) + "\n"
+ }.merge!(data)
+
+ ::Lograge.formatter.call(attributes) << "\n"
end
private
def process_params(data)
- return [] unless data.has_key?(:params)
+ return EMPTY_ARRAY unless data.has_key?(:params)
- params_array =
- data[:params]
- .each_pair
- .map { |k, v| { key: k, value: utf8_encode_values(v) } }
+ params_array = data[:params].map { |k, v| { key: k, value: utf8_encode_values(v) } }
- Gitlab::Utils::LogLimitedArray.log_limited_array(params_array,
- sentinel: { key: 'truncated', value: '...' })
+ Gitlab::Utils::LogLimitedArray.log_limited_array(params_array, sentinel: Gitlab::Lograge::CustomOptions::LIMITED_ARRAY_SENTINEL)
end
def utf8_encode_values(data)
case data
when Hash
- data.merge(data) { |k, v| utf8_encode_values(v) }
+ data.merge!(data) { |k, v| utf8_encode_values(v) }
when Array
- data.map { |v| utf8_encode_values(v) }
+ data.map! { |v| utf8_encode_values(v) }
when String
encode_utf8(data)
end