Class: Semlogr::Sinks::Seq::Sink

Inherits:
Batching
  • Object
show all
Defined in:
lib/semlogr/sinks/seq/sink.rb

Instance Method Summary collapse

Constructor Details

#initialize(client: nil, formatter: nil, **opts) ⇒ Sink

Returns a new instance of Sink.



10
11
12
13
14
15
# File 'lib/semlogr/sinks/seq/sink.rb', line 10

def initialize(client: nil, formatter: nil, **opts)
  @client = client || create_client(opts)
  @formatter = formatter || ClefFormatter.new

  super(opts)
end

Instance Method Details

#emit_batch(log_events) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/semlogr/sinks/seq/sink.rb', line 17

def emit_batch(log_events)
  payload = ''

  log_events.each do |log_event|
    payload << @formatter.format(log_event)
  end

  @client.post_events(payload)
end