Module: Taskinator::Logging

Defined in:
lib/taskinator/logger.rb

Defined Under Namespace

Classes: Pretty

Class Method Summary collapse

Class Method Details

.initialize_logger(log_target = STDOUT) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/taskinator/logger.rb', line 29

def initialize_logger(log_target = STDOUT)
  oldlogger = defined?(@logger) ? @logger : nil
  @logger = Logger.new(log_target)
  @logger.level = Logger::INFO
  @logger.formatter = Pretty.new
  oldlogger.close if oldlogger && !$TESTING # don't want to close testing's STDOUT logging
  @logger
end

.loggerObject



38
39
40
# File 'lib/taskinator/logger.rb', line 38

def logger
  defined?(@logger) ? @logger : initialize_logger
end

.logger=(log) ⇒ Object



42
43
44
# File 'lib/taskinator/logger.rb', line 42

def logger=(log)
  @logger = (log ? log : Logger.new('/dev/null'))
end