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

logger.rb « custom_emails « service_desk « concerns « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1817933c3d0240fa2251b92f00807828137bda61 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true

module ServiceDesk
  module CustomEmails
    module Logger
      private

      def log_warning(error_message: nil)
        with_context do
          Gitlab::AppLogger.warn(build_log_message(error_message: error_message))
        end
      end

      def log_info(error_message: nil, project: nil)
        with_context(project: project) do
          Gitlab::AppLogger.info(build_log_message(error_message: error_message))
        end
      end

      def with_context(project: nil, &block)
        Gitlab::ApplicationContext.with_context(
          related_class: self.class.to_s,
          user: current_user,
          project: project || self.project,
          &block
        )
      end

      def log_category
        'custom_email'
      end

      def build_log_message(error_message: nil)
        {
          category: log_category,
          error_message: error_message
        }.compact
      end
    end
  end
end