Module: Bellbro::Ringable

Included in:
Service, Worker
Defined in:
lib/bellbro/ringable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



3
4
5
# File 'lib/bellbro/ringable.rb', line 3

def self.included(klass)
  klass.extend(self)
end

.loggerObject



7
8
9
# File 'lib/bellbro/ringable.rb', line 7

def self.logger
  Bellbro::Settings.logger
end

Instance Method Details

#error(log_line) ⇒ Object



11
12
13
# File 'lib/bellbro/ringable.rb', line 11

def error(log_line)
  ring(log_line, type: :error)
end

#ring(log_line, opts = {}) ⇒ Object



15
16
17
18
19
20
# File 'lib/bellbro/ringable.rb', line 15

def ring(log_line, opts={})
  domain_insert = @domain ? "[#{@domain}]": ""
  error_insert = (opts[:type] == :error) ? "PlatformError " : ""
  complete_log_line = "[#{self.class}](#{Thread.current.object_id})#{domain_insert}: #{error_insert}#{log_line}"
  Bellbro::Settings.logger.info complete_log_line
end