Sha256: 254a3966c552fea3c8b8df06893830178d4d928eea1faf6f32ccf59c84652394

Contents?: true

Size: 850 Bytes

Versions: 1

Compression:

Stored size: 850 Bytes

Contents

# encoding: utf-8
require "logstash/codecs/base"
require "logstash/util/charset"

# The "s3_plain" codec is used for backward compatibility with previous version of the S3 Output
#
class LogStash::Codecs::S3Plain < LogStash::Codecs::Base
  config_name "s3_plain"

  SOURCE_FIELD = "source".freeze
  TAGS_FIELD = "tags".freeze
  MESSAGE_FIELD = "message".freeze

  def decode(data)
    raise RuntimeError.new("This codec is only used for backward compatibility with the previous S3 output.")
  end

  def encode(event)
    message = "Date: #{event.get(LogStash::Event::TIMESTAMP)}\n"
    message << "Source: #{event.get(SOURCE_FIELD)}\n"
    message << "Tags: #{Array(event.get(TAGS_FIELD)).join(', ')}\n"
    message << "Fields: #{event.to_hash.inspect}\n"
    message << "Message: #{event.get(MESSAGE_FIELD)}"

    @on_event.call(message)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-codec-s3plain-2.0.7 lib/logstash/codecs/s3_plain.rb