Class: Somadic::Logger

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

Constant Summary collapse

LOG_PATH =
"#{ENV['HOME']}/.somadic/"
LOG_FILE =
'somadic.log'

Class Method Summary collapse

Class Method Details

.debug(msg) ⇒ Object



8
9
10
# File 'lib/somadic/logger.rb', line 8

def self.debug(msg)
  instance.debug(msg)
end

.error(msg) ⇒ Object



16
17
18
# File 'lib/somadic/logger.rb', line 16

def self.error(msg)
  instance.error(msg)
end

.info(msg) ⇒ Object



12
13
14
# File 'lib/somadic/logger.rb', line 12

def self.info(msg)
  instance.info(msg)
end

.instanceObject



24
25
26
27
28
29
30
31
# File 'lib/somadic/logger.rb', line 24

def self.instance
  ::FileUtils.mkdir_p(LOG_PATH) unless File.directory?(LOG_PATH)
  l = MonoLogger.new(File.join(LOG_PATH, LOG_FILE), 'daily')
  l.formatter = proc do |severity, datetime, _, msg|
    "[#{severity}] #{datetime}: #{msg}\n"
  end
  l
end

.warn(msg) ⇒ Object



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

def self.warn(msg)
  instance.warn(msg)
end