Class: VCAP::Logging::Sink::StringSink

Inherits:
BaseSink
  • Object
show all
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

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(message)
  @mutex.synchronize { @str << message }
end