class 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
The StringIO instance the appender is writing to.
Public Class Methods
Source
# 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
Creates a new StringIo
appender that will append log messages to a StringIO instance.
Calls superclass method
Logging::Appenders::IO::new
Public Instance Methods
Source
# File lib/logging/appenders/string_io.rb, line 53 def clear @mutex.synchronize { @pos = 0 @sio.seek 0 @sio.truncate 0 } end
Clears the internal StringIO instance. All log messages are removed from the buffer.
Also aliased as: reset
Source
# 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
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.
Calls superclass method
Logging::Appenders::IO#reopen