summaryrefslogtreecommitdiff
path: root/lib/gitlab/grape_logging/loggers/user_logger.rb
blob: fa17286196774b79208548595e0d9ab0762b1a55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# This grape_logging module (https://github.com/aserafin/grape_logging) makes it
# possible to log the user who performed the Grape API action by retrieving
# the user context from the request environment.
module Gitlab
  module GrapeLogging
    module Loggers
      class UserLogger < ::GrapeLogging::Loggers::Base
        def parameters(request, _)
          params = request.env[::API::Helpers::API_USER_ENV]

          return {} unless params

          params.slice(:user_id, :username)
        end
      end
    end
  end
end