Class: Swoop::Rails

Inherits:
Object
  • Object
show all
Defined in:
lib/swoop/rails.rb

Class Method Summary collapse

Class Method Details

.log_levelObject



21
22
23
# File 'lib/swoop/rails.rb', line 21

def self.log_level
  ([(ENV["LOG_LEVEL"] || ::Rails.application.config.log_level).to_s.upcase, "INFO"] & %w[DEBUG INFO WARN ERROR FATAL UNKNOWN]).compact.first
end

.set_logger(config) ⇒ Object



3
4
5
# File 'lib/swoop/rails.rb', line 3

def self.set_logger(config)
  ::Rails.logger = config.logger = swoop_logger(config)
end

.swoop_logger(config) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/swoop/rails.rb', line 7

def self.swoop_logger(config)
  logger = if ENV["LOG_FILE"]
    ::ActiveSupport::Logger.new ::Rails.root.join(ENV["LOG_FILE"])
  else
    ::STDOUT.sync = true
    ::ActiveSupport::Logger.new(::STDOUT)
  end

  logger.level = Logger.const_get(log_level)
  logger.progname = config.log_progname
  logger.formatter = Swoop::Formatter.new
  return logger
end