summaryrefslogtreecommitdiff
path: root/lib/gitlab/external_authorization/logger.rb
blob: 61246cd870e6ba16eb5d667bd083fc37d5a0c56c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module Gitlab
  module ExternalAuthorization
    class Logger < ::Gitlab::Logger
      def self.log_access(access, project_path)
        status = access.has_access? ? "GRANTED" : "DENIED"
        message = ["#{status} #{access.user.email} access to '#{access.label}'"]

        message << "(#{project_path})" if project_path.present?
        message << "- #{access.load_type} #{access.loaded_at}" if access.load_type == :cache

        info(message.join(' '))
      end

      def self.file_name_noext
        'external-policy-access-control'
      end
    end
  end
end