Class: Logging::Appenders::IO

### Home Classes Methods

### In Files

- lib/logging/appenders/io.rb

### Parent

Logging::Appender

### Methods

- ::new
- #close

### Included Modules

- Logging::Appenders::Buffering

### Files

- History.txt

### Class/Module Index

Quicksearch

- Logging
- Logging::Appender
- Logging::Appenders
- Logging::Appenders::Buffering
- Logging::Appenders::File
- Logging::Appenders::IO
- Logging::Appenders::RollingFile
- Logging::Appenders::RollingFile::Roller
- Logging::Appenders::Stderr
- Logging::Appenders::Stdout
- Logging::Appenders::StringIo
- Logging::Appenders::Syslog
- Logging::ColorScheme
- Logging::Filter
- Logging::Filters
- Logging::Filters::Level
- Logging::Layout
- Logging::Layouts
- Logging::Layouts::Basic
- Logging::Layouts::Parseable
- Logging::Layouts::Pattern
- Logging::Logger
- Logging::MappedDiagnosticContext
- Logging::NestedDiagnosticContext
- Logging::Proxy
- Logging::RailsCompat
- Logging::Repository
- Logging::Repository::Singleton
- Logging::RootLogger
- RSpec
- RSpec::Core
- RSpec::Core::Configuration
- RSpec::LoggingHelper
- RSpec::LoggingHelper
- Spec
- Spec::Runner
- Spec::Runner::Configuration
- Object
- Object::LoggingHelper
- File
- FileUtils
- Module
- ReentrantMutex
- String

No matching classes.

# Logging::Appenders::IO

This class provides an Appender that can write to any IO stream configured for writing.

### Attributes

close_method[RW]

The method that will be used to close the IO stream. Defaults to :close but can be :close_read, :close_write or nil. When nil, the IO stream will not be closed when the appender's close method is called.

### Public Class Methods

new( name, io ) click to toggle source
new( name, io, :layout => layout )

Creates a new IO Appender using the given name that will use the io stream as the logging destination.

    # File lib/logging/appenders/io.rb, line 30
    def initialize( name, io, opts = {} )
      unless io.respond_to? :syswrite
        raise TypeError, "expecting an IO object but got '#{io.class.name}'"
      end

      @io = io
      @io.sync = true if io.respond_to? :sync=    # syswrite complains if the IO stream is buffered
      @io.flush rescue nil                        # syswrite also complains if in unbuffered mode and buffer isn't empty
      @close_method = :close

      super(name, opts)
      configure_buffering(opts)
    end

### Public Instance Methods

close( footer = true ) click to toggle source

Close the appender and writes the layout footer to the logging destination if the footer flag is set to `true`. Log events will no longer be written to the logging destination after the appender is closed.

    # File lib/logging/appenders/io.rb, line 52
    def close( *args )
      return self if @io.nil?
      super

      io, @io = @io, nil
      unless [STDIN, STDERR, STDOUT].include?(io)
        io.send(@close_method) if @close_method and io.respond_to? @close_method
      end
    rescue IOError
    ensure
      return self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.