Module: Devilicious::Log

Defined in:
lib/devilicious/log.rb

Class Method Summary collapse

Class Method Details

.debug(message, options = {}) ⇒ Object



18
19
20
# File 'lib/devilicious/log.rb', line 18

def debug message, options = {}
  info message, options if Devilicious.config.debug
end

.info(message, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/devilicious/log.rb', line 7

def info message, options = {}
  options = {
    output: $stdout,
    timestamp: true
  }.merge(options)

  message = "#{Time.now} #{message}" if options.fetch(:timestamp)

  @semaphore.synchronize { options.fetch(:output).puts message }
end

.warn(message, options = {}) ⇒ Object



22
23
24
25
26
# File 'lib/devilicious/log.rb', line 22

def warn message, options = {}
  options = {output: $stderr}.merge(options)

  info "[WARN] #{message}", options
end