Ticket #8347: logger.rb_add_outputfile.patch
| File logger.rb_add_outputfile.patch, 1.0 kB (added by lhartley, 2 years ago) |
|---|
-
logger.rb
old new 9 9 10 10 MAX_LEVEL = 3 11 11 12 def initialize(options={}) 13 output = options[:output] || STDERR 12 def initialize() 13 setDevice() 14 @level = 0 15 end 16 17 def close 18 @device.close if @needs_close 19 end 20 21 def setDevice(options={}) 22 output = options[:device] || STDERR 23 output = STDERR if output = "" 14 24 case 15 25 when output.respond_to?(:puts) 16 26 @device = output … … 18 28 @device = File.open(output.to_str, "a") 19 29 @needs_close = true 20 30 end 21 22 @options = options 23 @level = 0 31 @options = options 24 32 end 25 26 def close 27 @device.close if @needs_close 28 end 29 33 30 34 def log(level, message, line_prefix=nil) 31 35 if level <= self.level 32 36 indent = "%*s" % [MAX_LEVEL, "*" * (MAX_LEVEL - level)]