Class: LogStash::Inputs::File

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/inputs/file.rb

Defined Under Namespace

Classes: Reader

Instance Attribute Summary

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Base

#tag

Constructor Details

#initialize(url, type, config = {}, &block) ⇒ File

Returns a new instance of File.



8
9
10
11
12
13
14
# File 'lib/logstash/inputs/file.rb', line 8

def initialize(url, type, config={}, &block)
  super

  # Hack the hostname into the url.
  # This works since file:// urls don't generally have a host in it.
  @url.host = Socket.gethostname
end

Instance Method Details

#receive(filetail, event) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/logstash/inputs/file.rb', line 24

def receive(filetail, event)
  url = @url.clone
  url.path = filetail.path
  @logger.debug(["original url", { :originalurl => @url, :newurl => url }])
  event = LogStash::Event.new({
    "@message" => event,
    "@type" => @type,
    "@tags" => @tags.clone,
  })
  event.source = url
  @logger.debug(["Got event", event])
  @callback.call(event)
end

#registerObject



17
18
19
20
21
# File 'lib/logstash/inputs/file.rb', line 17

def register
  @logger.info("Registering #{@url}")
  EventMachine::FileGlobWatchTail.new(@url.path, Reader, interval=60,
                                      exclude=[], receiver=self)
end