Class: Forklift::Base::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/forklift/base/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(forklift) ⇒ Logger

Returns a new instance of Logger.



7
8
9
# File 'lib/forklift/base/logger.rb', line 7

def initialize(forklift)
  @forklift = forklift
end

Instance Method Details

#debug(message) ⇒ Object



31
32
33
34
35
# File 'lib/forklift/base/logger.rb', line 31

def debug(message)
  if forklift.config[:logger][:debug] == true
    log("[debug] #{message}")
  end
end

#emphatically(message) ⇒ Object



37
38
39
40
41
# File 'lib/forklift/base/logger.rb', line 37

def emphatically(message)
  log "" if message.length > 0
  log "*** #{message} ***"
  log ""
end

#fatal(message) ⇒ Object



43
44
45
# File 'lib/forklift/base/logger.rb', line 43

def fatal(message)
  log "!!! #{message} !!!"
end

#forkliftObject



11
12
13
# File 'lib/forklift/base/logger.rb', line 11

def forklift
  @forklift
end

#log(message, severity = "info") ⇒ Object



24
25
26
27
28
29
# File 'lib/forklift/base/logger.rb', line 24

def log(message, severity="info")
  timed_message = "[Forklift @ #{Time.now}] #{message}"
  puts timed_message unless forklift.config[:logger][:stdout] != true
  logger.send(severity.to_sym, message) unless logger.nil?
  messages << timed_message
end

#loggerObject



19
20
21
22
# File 'lib/forklift/base/logger.rb', line 19

def logger
  log_dir = "#{forklift.config[:project_root]}/log"
  @logger ||= ::Lumberjack::Logger.new("#{log_dir}/forklift.log", buffer_size: 0)
end

#messagesObject



15
16
17
# File 'lib/forklift/base/logger.rb', line 15

def messages
  @messages ||= []
end