Class: LogStash::Inputs::File
Defined Under Namespace
Classes: Reader
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(url, type, config = {}, &block) ⇒ File
constructor
A new instance of File.
- #receive(filetail, event) ⇒ Object
- #register ⇒ Object
Methods inherited from Base
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 |
#register ⇒ Object
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 |