Class: LogSinks::Sink

Inherits:
Object
  • Object
show all
Defined in:
lib/log_sinks/sink.rb

Overview

Sink receives log event and writes to a permanent storage.

Direct Known Subclasses

IOSink

Instance Method Summary collapse

Constructor Details

#initialize(pump_class: LogSinks::Pumps::InThreadPump) ⇒ Sink

Returns a new instance of Sink.



9
10
11
12
# File 'lib/log_sinks/sink.rb', line 9

def initialize(pump_class: LogSinks::Pumps::InThreadPump)
  @filters = []
  @pump = pump_class.new(self)
end

Instance Method Details

#add_filter(filter) ⇒ Object



24
25
26
# File 'lib/log_sinks/sink.rb', line 24

def add_filter(filter)
  @filters << filter
end

#drain(_event) ⇒ Object

Receives a message and write to a permanent storage



29
30
31
# File 'lib/log_sinks/sink.rb', line 29

def drain(_event)
  nil
end

#flushObject



14
15
16
# File 'lib/log_sinks/sink.rb', line 14

def flush
  @has_events_flag.set if @thread_model == :dedicated_thread
end

#receive(event) ⇒ Object



18
19
20
21
22
# File 'lib/log_sinks/sink.rb', line 18

def receive(event)
  return unless accept_event?(event)

  @pump.receive event
end