Class: SiteMapper::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/site_mapper/logger.rb

Overview

Handles logging

Defined Under Namespace

Modules: NilLogger, SystemOutLogger

Class Method Summary collapse

Class Method Details

.err_log(err_msg) ⇒ Object



31
32
33
34
# File 'lib/site_mapper/logger.rb', line 31

def self.err_log(err_msg)
  @@log ||= use_logger_type(:default)
  @@log.err_log(err_msg)
end

.log(msg) ⇒ Object



25
26
27
28
# File 'lib/site_mapper/logger.rb', line 25

def self.log(msg)
  @@log ||= use_logger_type(:default)
  @@log.log(msg)
end

.use_logger(logger) ⇒ Object



19
20
21
22
# File 'lib/site_mapper/logger.rb', line 19

def self.use_logger(logger)
  fail 'Logger already set' if defined?(@@log)
  @@log = logger
end

.use_logger_type(type) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/site_mapper/logger.rb', line 5

def self.use_logger_type(type)
  fail 'Logger already set' if defined?(@@log)
  @@log = case type.to_s
  when 'nil', 'default'
    NilLogger
  when 'system'
    SystemOutLogger
  else
    fail ArgumentError, "Unknown logger type: '#{type}'"
  end
  @@log
end