Sha256: b7a9e203209d597c3551729d3a7f2cb7ba29fc25b658c05bfc7f3c55b2d4f153
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
# :nodoc: require "log4r-color/outputter/outputter" require "log4r-color/staticlogger" module Log4r ## # 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. class IOOutputter < Outputter # IOOutputter needs an IO object to write to. def initialize(_name, _out, hash={}) super(_name, hash) @out = _out end def closed? @out.closed? end # Close the IO and sets level to OFF 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 ####### private ####### # perform the write 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
log4r-color-1.2.2 | lib/log4r-color/outputter/iooutputter.rb |
log4r-color-1.2 | lib/log4r-color/outputter/iooutputter.rb |