Class: MediaShelf::Log
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
- #d(msg) ⇒ Object
- #e(msg) ⇒ Object
- #f(msg) ⇒ Object
- #i(msg) ⇒ Object
-
#initialize ⇒ Log
constructor
A new instance of Log.
- #silence! ⇒ Object
- #unsilence! ⇒ Object
- #w(msg) ⇒ Object
Constructor Details
#initialize ⇒ Log
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 |