lib/fusuma/multi_logger.rb in fusuma-2.0.5 vs lib/fusuma/multi_logger.rb in fusuma-2.1.0
- old
+ new
@@ -9,12 +9,24 @@
include Singleton
attr_reader :err_logger
attr_accessor :debug_mode
+ @@filepath = nil
+ def self.filepath=(filepath)
+ @@filepath = filepath
+ end
+
def initialize
- super($stdout)
- @err_logger = Logger.new($stderr)
+ if @@filepath
+ logfile = File.new(@@filepath, 'a')
+ super(logfile)
+ $stderr = logfile
+ @err_logger = Logger.new($stderr)
+ else
+ super($stdout)
+ @err_logger = Logger.new($stderr)
+ end
@debug_mode = false
end
def debug(msg)
return unless debug_mode?