Class: Logging::Appenders::StringIo

### Home Classes Methods

### In Files

- lib/logging/appenders/string_io.rb

### Parent

Logging::Appenders::IO

### Methods

- ::new
- #clear
- #reopen
- #reset

### Files

- History.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Logging
- Logging::Appender
- Logging::Appenders
- Logging::Appenders::Buffering
- Logging::Appenders::Email
- Logging::Appenders::File
- Logging::Appenders::Growl
- Logging::Appenders::IO
- Logging::Appenders::RollingFile
- Logging::Appenders::Stderr
- Logging::Appenders::Stdout
- Logging::Appenders::StringIo
- Logging::Appenders::Syslog
- Logging::ColorScheme
- Logging::Config
- Logging::Config::Configurator
- Logging::Config::Configurator::DSL
- Logging::Config::Configurator::Error
- Logging::Config::Configurator::TopLevelDSL
- Logging::Config::YamlConfigurator
- Logging::Config::YamlConfigurator::Error
- 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
- Logging::Stats
- Logging::Stats::Sampler
- Logging::Stats::Tracker
- RSpec
- RSpec::Core
- RSpec::Core::Configuration
- RSpec::LoggingHelper
- RSpec::LoggingHelper
- Spec
- Spec::Runner
- Spec::Runner::Configuration
- Object
- Object::LoggingHelper
- File
- FileUtils
- Hash
- Kernel
- Module
- ReentrantMutex
- String

No matching classes.

# Logging::Appenders::StringIo

This class provides an Appender that can write to a StringIO instance. This is very useful for testing log message output.

### Attributes

sio[R]

The StringIO instance the appender is writing to.

### Public Class Methods

new( name, opts = {} ) click to toggle source

Creates a new StringIo appender that will append log messages to a StringIO instance.

    # File lib/logging/appenders/string_io.rb, line 25
    def initialize( name, opts = {} )
      @sio = StringIO.new
      @sio.extend IoToS
      @pos = 0
      super(name, @sio, opts)
    end

### Public Instance Methods

clear() click to toggle source

Clears the internal StringIO instance. All log messages are removed from the buffer.

    # File lib/logging/appenders/string_io.rb, line 53
    def clear
      @mutex.synchronize {
        @pos = 0
        @sio.seek 0
        @sio.truncate 0
      }
    end

Also aliased as: reset
reopen() click to toggle source

Reopen the underlying StringIO instance. If the instance is currently closed then it will be opened. If the instance is currently open then it will be closed and immediately opened.

    # File lib/logging/appenders/string_io.rb, line 36
    def reopen
      @mutex.synchronize {
        if defined? @io and @io
          flush
          @io.close rescue nil
        end
        @io = @sio = StringIO.new
        @sio.extend IoToS
        @pos = 0
      }
      super
      self
    end

reset() click to toggle source
Alias for: clear

[Validate]

Generated with the Darkfish Rdoc Generator 2.