Class: Log4r::IOOutputter

Inherits:
Outputter
  • Object
show all
Defined in:
lib/log4r/outputter/iooutputter.rb

Overview

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.

Direct Known Subclasses

FileOutputter, StderrOutputter, StdoutOutputter

Instance Attribute Summary

Attributes inherited from Outputter

#formatter, #level, #name

Instance Method Summary collapse

Methods inherited from Outputter

[], []=, each, each_outputter, #flush, #only_at, stderr, stdout

Constructor Details

#initialize(_name, _out, hash = {}) ⇒ IOOutputter

IOOutputter needs an IO object to write to.



18
19
20
21
# File 'lib/log4r/outputter/iooutputter.rb', line 18

def initialize(_name, _out, hash={})
  super(_name, hash)
  @out = _out
end

Instance Method Details

#closeObject

Close the IO and sets level to OFF



28
29
30
31
32
33
# File 'lib/log4r/outputter/iooutputter.rb', line 28

def close
  @out.close unless @out.nil? || closed?
  @level = OFF
  OutputterFactory.create_methods(self)
  Logger.log_internal {"Outputter '#{@name}' closed IO and set to OFF"}
end

#closed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/log4r/outputter/iooutputter.rb', line 23

def closed?
  @out.closed?
end