Class: LogRunes::LoggerFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/log_runes/logger_factory.rb

Class Method Summary collapse

Class Method Details

.set(config, opts) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/log_runes/logger_factory.rb', line 4

def self.set(config, opts)

  if Rails.env.development? || Rails.env.test?
    # Use a stdout logger to avoid piling up a mostly useless giant log file
    stdout_logger = Logger.new(STDOUT)
    config.logger = ActiveSupport::TaggedLogging.new(stdout_logger)
    return
  end
  
  log_base = opts[:dir] || "#{Rails.root}/log"
  log_name = opts[:name] || Rails.env
  l = Logger.new("#{log_base}/#{log_name}.log", 'daily')

  config.logger = opts[:not_tagged] ? l : ActiveSupport::TaggedLogging.new(l)

end