debian-mirror-gitlab/lib/gitlab/grape_logging/loggers/response_logger.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
582 B
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
module Gitlab
module GrapeLogging
module Loggers
class ResponseLogger < ::GrapeLogging::Loggers::Base
def parameters(_, response)
return {} unless Feature.enabled?(:log_response_length)
response_bytes = 0
2023-07-09 08:55:56 +05:30
case response
when String
response_bytes = response.bytesize
else
response.each { |resp| response_bytes += resp.to_s.bytesize }
end
2022-08-13 15:12:31 +05:30
{
response_bytes: response_bytes
}
end
end
end
end
end