Parent

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
25:     def initialize( name, opts = {} )
26:       @sio = StringIO.new
27:       @sio.extend IoToS
28:       @pos = 0
29:       super(name, @sio, opts)
30:     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
53:     def clear
54:       @mutex.synchronize {
55:         @pos = 0
56:         @sio.seek 0
57:         @sio.truncate 0
58:       }
59:     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
36:     def reopen
37:       @mutex.synchronize {
38:         if defined? @io and @io
39:           flush
40:           @io.close rescue nil
41:         end
42:         @io = @sio = StringIO.new
43:         @sio.extend IoToS
44:         @pos = 0
45:       }
46:       super
47:       self
48:     end
reset() click to toggle source
Alias for: clear

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.