lib/filum/logger.rb in filum-1.0.3 vs lib/filum/logger.rb in filum-2.0.0
- old
+ new
@@ -1,15 +1,28 @@
require 'logger'
module Filum
class Logger < ::Logger
- def initialize(*args)
- super
- self.formatter = Filum::LogFormatter.new
+ attr_reader :logfile
+ def initialize(logfile, options = {})
+ @logfile = logfile
+ create_log_directory
+
+ super(logfile, shift_age='daily')
+ self.formatter = Filum::LogFormatter.new(options)
+ self.level = Logger::INFO
end
def context_id=(context_id)
Thread.current[:context_id] = context_id
+ end
+
+ private
+ def create_log_directory
+ dir = File.dirname(@logfile)
+ unless File.directory?(dir)
+ FileUtils.mkdir_p(dir)
+ end
end
end
end