Class: OptionalLogger

Inherits:
Object show all
Defined in:
lib/tmdb/optional_logger.rb

Overview

An optional logger. If initialized with a logger instance, uses the logger otherwise doesn’t do anything. Basically trying to not require a particular logger class.

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ OptionalLogger

logger may be nil or a logger instance



7
8
9
# File 'lib/tmdb/optional_logger.rb', line 7

def initialize(logger)
  @logger = logger
end

Instance Method Details

#debug(&blk) ⇒ Object

debug …



12
13
14
# File 'lib/tmdb/optional_logger.rb', line 12

def debug(&blk)
  @logger.debug(blk.call) unless @logger.nil?
end

#error(&blk) ⇒ Object

error …



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

def error(&blk)
  @logger.error(blk.call) unless @logger.nil?
end

#info(&blk) ⇒ Object

info …



17
18
19
# File 'lib/tmdb/optional_logger.rb', line 17

def info(&blk)
  @logger.info(blk.call) unless @logger.nil?
end

#warn(&blk) ⇒ Object

warn …



22
23
24
# File 'lib/tmdb/optional_logger.rb', line 22

def warn(&blk)
  @logger.warn(blk.call) unless @logger.nil?
end