Class: LoggerConfigurer

Inherits:
Object
  • Object
show all
Defined in:
lib/web-scraper/logger_configurer.rb

Constant Summary collapse

DEFAULT_FILENAME =
'web-scraper.log'

Class Method Summary collapse

Class Method Details

.create_logger(options = {}) ⇒ Object



7
8
9
10
11
12
# File 'lib/web-scraper/logger_configurer.rb', line 7

def self.create_logger(options = {})        
  
  @logger = Logger.new logger_device(options[:log_to_file])    
  @logger.level      = options[:log_level].to_i if options[:log_level]
  @logger    
end

.logger_device(file_option) ⇒ Object



14
15
16
17
18
# File 'lib/web-scraper/logger_configurer.rb', line 14

def self.logger_device(file_option)
  return nil if not file_option and ENV["WEBSCRAPER_ENV"] == 'test'

  file_option ? DEFAULT_FILENAME : STDOUT    
end