Sha256: e05ee11b6e5227b64bf95b775a9605255478864507aa3f8d2686e98d68c38cb5

Contents?: true

Size: 610 Bytes

Versions: 1

Compression:

Stored size: 610 Bytes

Contents

require "json"
require "time"
require "date"

module LogStasher
  class Event

    def initialize(data={})
      @cancelled = false

      @data = data
      if data.include?("@timestamp")
        t = data["@timestamp"]
        if t.is_a?(String)
          data["@timestamp"] = Time.parse(t).gmtime
        end
      else
        data["@timestamp"] = ::Time.now.utc 
      end
      data["@version"] = "1" if !@data.include?("@version")
    end 

    def to_s
      to_json.to_s
    end
    
    def to_json(*args)
      return @data.to_json(*args) 
    end

    def [](key)
      @data[key]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstasher-1.4.0 lib/logstasher/event.rb