Module: Integrations::Loggable

Included in:
Integration
Defined in:
app/models/concerns/integrations/loggable.rb

Instance Method Summary collapse

Instance Method Details

#build_message(message, params = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'app/models/concerns/integrations/loggable.rb', line 23

def build_message(message, params = {})
  {
    integration_class: self.class.name,
    integration_id: id,
    project_id: project&.id,
    project_path: project&.full_path,
    message: message
  }.merge(params)
end

#log_error(message, params = {}) ⇒ Object



11
12
13
14
15
# File 'app/models/concerns/integrations/loggable.rb', line 11

def log_error(message, params = {})
  message = build_message(message, params)

  logger.error(message)
end

#log_exception(error, params = {}) ⇒ Object



17
18
19
20
21
# File 'app/models/concerns/integrations/loggable.rb', line 17

def log_exception(error, params = {})
  Gitlab::ExceptionLogFormatter.format!(error, params)

  log_error(params[:message] || error.message, params)
end

#log_info(message, params = {}) ⇒ Object



5
6
7
8
9
# File 'app/models/concerns/integrations/loggable.rb', line 5

def log_info(message, params = {})
  message = build_message(message, params)

  logger.info(message)
end

#loggerObject



33
34
35
# File 'app/models/concerns/integrations/loggable.rb', line 33

def logger
  Gitlab::IntegrationsLogger
end