class Log4r::IOOutputter
IO Outputter
invokes print then flush on the wrapped IO object. If the IO stream dies, IOOutputter
sets itself to OFF and the system continues on its merry way.
To find out why an IO stream died, create a logger named ‘log4r’ and look at the output.
Public Class Methods
new(_name, _out, hash={})
click to toggle source
IOOutputter
needs an IO object to write to.
Calls superclass method
# File lib/log4r/outputter/iooutputter.rb, line 18 def initialize(_name, _out, hash={}) super(_name, hash) @out = _out end
Public Instance Methods
close()
click to toggle source
Close the IO and sets level to OFF
# File lib/log4r/outputter/iooutputter.rb, line 28 def close @out.close unless @out.nil? @level = OFF OutputterFactory.create_methods(self) Logger.log_internal {"Outputter '#{@name}' closed IO and set to OFF"} end
closed?()
click to toggle source
# File lib/log4r/outputter/iooutputter.rb, line 23 def closed? @out.closed? end
Private Instance Methods
write(data)
click to toggle source
perform the write
# File lib/log4r/outputter/iooutputter.rb, line 40 def write(data) begin @out.print data @out.flush rescue IOError => ioe # recover from this instead of crash Logger.log_internal {"IOError in Outputter '#{@name}'!"} Logger.log_internal {ioe} close rescue NameError => ne Logger.log_internal {"Outputter '#{@name}' IO is #{@out.class}!"} Logger.log_internal {ne} close end end