Class: Fluent::Plugin::LogentriesSSL::MessageHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/logentries_ssl/message_helper.rb

Constant Summary collapse

MAX_SIZE =

logentries ‘We have an ingestion limit of 64k per logevent’ better go with the lower 64k for safety

60_000
MIN_SIZE =
100

Class Method Summary collapse

Class Method Details

.split_record(token, payload, max_size = MAX_SIZE) ⇒ Object

Do splitting ad-hoc instead of fancy



10
11
12
13
14
15
16
17
# File 'lib/fluent/plugin/logentries_ssl/message_helper.rb', line 10

def self.split_record(token, payload, max_size = MAX_SIZE)
  max_size = [max_size, MIN_SIZE].max
  return [payload] if payload.nil? || payload.bytesize < max_size
  splitsize = payload.bytesize
  splitsize /= 2 while(splitsize > max_size)
  parts = payload.scan(/.{1,#{splitsize}}/)
  return parts.collect {|x| "#{token} #{x} \n" }
end