Class: EventShipper::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/event_shipper/event.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, path, line) ⇒ Event

Returns a new instance of Event.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/event_shipper/event.rb', line 6

def initialize host, path, line
  @path = path
  @line = line
  @host = host
  @timestamp = Time.now.utc.iso8601(6)
  @source = Addressable::URI.new(
    :scheme => 'file', 
    :host => host, :path => path)
  @message = line.chomp.strip
  @fields = {}
  @tags = %w(shipped)
end

Instance Method Details

#to_hashObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/event_shipper/event.rb', line 19

def to_hash
  {
    '@source' => @source.to_s,
    '@type' => @source.scheme,
    '@tags' => @tags,
    '@fields' => @fields,
    '@timestamp' => @timestamp,
    '@source_host' => @host,
    '@source_path' => @path,
    '@message' => @message
  }
end