Sha256: 2dd27384b122173914b578ac13c81fcc433d877e62c4154c17a155a3caf6081a

Contents?: true

Size: 506 Bytes

Versions: 6

Compression:

Stored size: 506 Bytes

Contents

require 'base64'
require 'json'
require 'stringio'
require 'zlib'

module Jets::Job::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

6 entries across 6 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/job/helpers/log_event.rb
jets-5.0.12 lib/jets/job/helpers/log_event.rb
jets-5.0.11 lib/jets/job/helpers/log_event.rb
jets-5.0.10 lib/jets/job/helpers/log_event.rb
jets-5.0.9 lib/jets/job/helpers/log_event.rb
jets-5.0.8 lib/jets/job/helpers/log_event.rb