Class: Semlogr::Sinks::Logentries::Sink

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Sink.



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

def initialize(token, formatter: nil, **opts)
  @token = token
  @formatter = formatter || Formatters::JsonFormatter.new
  @connection = create_connection(opts)

  super(opts)
end

Instance Method Details

#emit_batch(items) ⇒ Object



17
18
19
20
21
22
# File 'lib/semlogr/sinks/logentries/sink.rb', line 17

def emit_batch(items)
  items.each do |item|
    output = @formatter.format(item)
    @connection.write("#{@token} #{output}")
  end
end