Class: Baleen::BL

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/baleen/utils/logger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBL

Returns a new instance of BL.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/baleen/utils/logger.rb', line 28

def initialize
  config = Baleen::Configuration.instance

  if config.debug
    device = STDOUT
  else
    dir = File.join(config.dir, "log")
    FileUtils.mkdir_p dir
    device = File.join(dir, "baleen.log")
    Celluloid.logger = nil
  end
  @log = Logger.new(device)
  @log.level = config.log_level
end

Instance Attribute Details

#logObject (readonly)

Returns the value of attribute log.



26
27
28
# File 'lib/baleen/utils/logger.rb', line 26

def log
  @log
end

Class Method Details

.debug(msg) ⇒ Object



58
59
60
61
# File 'lib/baleen/utils/logger.rb', line 58

def self.debug(msg)
  instance.log.debug(msg.magenta)
  EoL.new(Proc.new{instance.log.debug("")})
end

.error(msg) ⇒ Object



43
44
45
46
# File 'lib/baleen/utils/logger.rb', line 43

def self.error(msg)
  instance.log.error(msg.red)
  EoL.new(Proc.new{instance.log.error("")})
end

.info(msg) ⇒ Object



53
54
55
56
# File 'lib/baleen/utils/logger.rb', line 53

def self.info(msg)
  instance.log.info(msg)
  EoL.new(Proc.new{instance.log.info("")})
end

.notice(msg) ⇒ Object



63
64
65
66
# File 'lib/baleen/utils/logger.rb', line 63

def self.notice(msg)
  instance.log.info(msg.green)
  EoL.new(Proc.new{instance.log.info("")})
end

.warn(msg) ⇒ Object



48
49
50
51
# File 'lib/baleen/utils/logger.rb', line 48

def self.warn(msg)
  instance.log.warn(msg.yellow)
  EoL.new(Proc.new{instance.log.warn("")})
end

Instance Method Details

#puts(msg) ⇒ Object



68
69
70
# File 'lib/baleen/utils/logger.rb', line 68

def puts(msg)
  log.info(msg)
end