Module: Cassie::Logger

Defined in:
lib/cassie/logger.rb

Class Method Summary collapse

Class Method Details

.init_logger(target = STDOUT) ⇒ Object


12
13
14
15
16
17
18
19
20
21
# File 'lib/cassie/logger.rb', line 12

def self.init_logger(target = STDOUT)
  previous_logger = defined?(@logger) ? @logger : nil

  @logger = ::Logger.new(target)
  @logger.level = ::Logger::INFO
  @logger.formatter = log_formatter

  previous_logger.close if previous_logger
  @logger
end

.log_formatterObject


23
24
25
# File 'lib/cassie/logger.rb', line 23

def self.log_formatter
  ActiveSupport::Logger::SimpleFormatter.new
end

.loggerObject


4
5
6
# File 'lib/cassie/logger.rb', line 4

def self.logger
  @logger ||= init_logger
end

.logger=(new_logger) ⇒ Object


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

def self.logger=(new_logger)
  @logger = new_logger || ::Logger.new('/dev/null')
end