Class: Semlogr::Sinks::Logentries::Sink
- Inherits:
-
Batching
- Object
- Batching
- Semlogr::Sinks::Logentries::Sink
- Defined in:
- lib/semlogr/sinks/logentries/sink.rb
Instance Method Summary collapse
- #emit_batch(items) ⇒ Object
-
#initialize(token, formatter: nil, **opts) ⇒ Sink
constructor
A new instance of Sink.
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 |