Class: LogSinks::IOSink
Overview
Sink that writes log events to IO stream, e.g., STDOUT or file stream
Instance Attribute Summary collapse
-
#formatter ⇒ Object
writeonly
Sets the attribute formatter.
Instance Method Summary collapse
- #drain(event) ⇒ Object
-
#initialize(io, pump_class: LogSinks::Pumps::InThreadPump) ⇒ IOSink
constructor
A new instance of IOSink.
Methods inherited from Sink
Constructor Details
#initialize(io, pump_class: LogSinks::Pumps::InThreadPump) ⇒ IOSink
Returns a new instance of IOSink.
9 10 11 12 13 |
# File 'lib/log_sinks/io_sink.rb', line 9 def initialize(io, pump_class: LogSinks::Pumps::InThreadPump) super(pump_class: pump_class) @io = io @formatter = ::LogSinks::Formatter.new end |
Instance Attribute Details
#formatter=(value) ⇒ Object (writeonly)
Sets the attribute formatter
15 16 17 |
# File 'lib/log_sinks/io_sink.rb', line 15 def formatter=(value) @formatter = value end |
Instance Method Details
#drain(event) ⇒ Object
17 18 19 20 |
# File 'lib/log_sinks/io_sink.rb', line 17 def drain(event) txt = @formatter.call(event) @io.write(txt) end |