Class: MediaShelf::Log

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/log.rb

Overview

A singleton logger. That way we can use the same instance all over the place. Singleton claims to be threadsafe.

Instance Method Summary collapse

Constructor Details

#initializeLog

Returns a new instance of Log.



14
15
16
17
# File 'lib/log.rb', line 14

def initialize
  @logger = Logger.new(STDOUT)
  @logger.datetime_format = "%y%m%d %H:%M:%S"
end

Instance Method Details

#d(msg) ⇒ Object



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

def d(msg)
  @logger.debug msg if @logger.level == Logger::DEBUG
end

#e(msg) ⇒ Object



21
22
23
# File 'lib/log.rb', line 21

def e(msg)
  @logger.error msg
end

#f(msg) ⇒ Object



30
31
32
# File 'lib/log.rb', line 30

def f(msg)
  @logger.fatal msg
end

#i(msg) ⇒ Object



27
28
29
# File 'lib/log.rb', line 27

def i(msg)
  @logger.info msg
end

#silence!Object



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

def silence!
  @logger = Logger.new(File.open('/dev/null', 'w')) 
end

#unsilence!Object



11
12
13
# File 'lib/log.rb', line 11

def unsilence!
  @logger = Logger.new(STDOUT)
end

#w(msg) ⇒ Object



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

def w(msg)
  @logger.warn msg
end