Class: VCAP::Logging::Sink::StringSink
- Defined in:
- lib/vcap/logging/sink/string_sink.rb
Overview
A sink for writing data to a string. Useful if you want to capture logs in memory along with writing to a file.
Instance Attribute Summary
Attributes inherited from BaseSink
#autoflush, #formatter, #opened
Instance Method Summary collapse
-
#initialize(str, formatter = nil) ⇒ StringSink
constructor
A new instance of StringSink.
- #write(message) ⇒ Object
Methods inherited from BaseSink
#add_record, #close, #flush, #open
Constructor Details
#initialize(str, formatter = nil) ⇒ StringSink
Returns a new instance of StringSink.
8 9 10 11 12 |
# File 'lib/vcap/logging/sink/string_sink.rb', line 8 def initialize(str, formatter=nil) super(formatter) @str = str open end |
Instance Method Details
#write(message) ⇒ Object
14 15 16 |
# File 'lib/vcap/logging/sink/string_sink.rb', line 14 def write() @mutex.synchronize { @str << } end |