Sha256: 631142022e556a1955c670639f8c644cc98232fc090b849529742c7ccc2ee6e2

Contents?: true

Size: 508 Bytes

Versions: 4

Compression:

Stored size: 508 Bytes

Contents

require "base64"
require "json"
require "stringio"
require "zlib"

module Jets::Event::Helpers
  module LogEvent
    def log_event
      encoded = event["awslogs"]["data"]
      compressed_string = Base64.decode64(encoded)
      gz = Zlib::GzipReader.new(StringIO.new(compressed_string))
      uncompressed_string = gz.read
      data = JSON.load(uncompressed_string)
      ActiveSupport::HashWithIndifferentAccess.new(data)
    end

    def log_event?
      !!event.dig("awslogs", "data")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jets-6.0.5 lib/jets/event/helpers/log_event.rb
jets-6.0.4 lib/jets/event/helpers/log_event.rb
jets-6.0.3 lib/jets/event/helpers/log_event.rb
jets-6.0.2 lib/jets/event/helpers/log_event.rb