Class: Marty::Logger

Inherits:
Object
  • Object
show all
Includes:
Delorean::Model
Defined in:
lib/marty/logger.rb

Class Method Summary collapse

Class Method Details

.debug(*args) ⇒ Object



20
21
22
# File 'lib/marty/logger.rb', line 20

def debug(*args)
  log_event(:debug, *args)
end

.error(*args) ⇒ Object



32
33
34
# File 'lib/marty/logger.rb', line 32

def error(*args)
  log_event(:error, *args)
end

.fatal(*args) ⇒ Object



36
37
38
# File 'lib/marty/logger.rb', line 36

def fatal(*args)
  log_event(:fatal, *args)
end

.info(*args) ⇒ Object



24
25
26
# File 'lib/marty/logger.rb', line 24

def info(*args)
  log_event(:info, *args)
end

.log(type, message, details = nil) ⇒ Object



44
45
46
# File 'lib/marty/logger.rb', line 44

def log(type, message, details = nil)
  Marty::Log.write_log(type, message, details)
end

.log_event(event_name, *args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/marty/logger.rb', line 9

def log_event(event_name, *args)
  if Marty::Util.logger.respond_to?(event_name)
    Marty::Util.logger.send(
      event_name,
      args[0]
    )
  end

  log(event_name, *args)
end

.unknown(*args) ⇒ Object



40
41
42
# File 'lib/marty/logger.rb', line 40

def unknown(*args)
  log_event(:unknown, *args)
end

.warn(*args) ⇒ Object



28
29
30
# File 'lib/marty/logger.rb', line 28

def warn(*args)
  log_event(:warn, *args)
end

.with_logging(error_message, error_data) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/marty/logger.rb', line 48

def with_logging(error_message, error_data)
  yield
rescue StandardError => e
  error(
    error_message,
    'message' => e.message,
    'data' => error_data
  )

  raise "#{error_message}: #{e.message}"
end