5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/log_runes/logger_factory.rb', line 5
def self.set(config, opts)
if Rails.env.development? || Rails.env.test?
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
return
end
return if opts[:no_cronolog]
cronolog_path = opts[:cronolog_path] || '/usr/bin/cronolog'
unless File.exists? cronolog_path
puts "cronolog missing - reverting to standard logger"
return
end
log_base = opts[:dir] || "#{Rails.root}/log"
log_name = opts[:name] || Rails.env
crono_cmd = "#{cronolog_path} -S #{log_base}/#{log_name}.log #{log_base}/rot/#{log_name}-%Y-%m-%d.log"
l = Logger.new(IO.popen(crono_cmd, "w"))
config.logger = opts[:not_tagged] ? l : ActiveSupport::TaggedLogging.new(l)
end
|