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

response_logger.rb « loggers « grape_logging « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b87566a62b04846bd626faf6f950595e8cf81a8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

module Gitlab
  module GrapeLogging
    module Loggers
      class ResponseLogger < ::GrapeLogging::Loggers::Base
        def parameters(_, response)
          response_bytes = 0

          case response
          when String
            response_bytes = response.bytesize
          else
            response.each { |resp| response_bytes += resp.to_s.bytesize }
          end

          {
            response_bytes: response_bytes
          }
        end
      end
    end
  end
end