Class: LogStash::Inputs::FileListener
- Inherits:
-
Object
- Object
- LogStash::Inputs::FileListener
- Defined in:
- lib/logstash/inputs/file_listener.rb
Overview
As and when a new WatchedFile is processed FileWatch asks for an instance of this class for the file path of that WatchedFile. All subsequent callbacks are sent via this listener instance. The file is essentially a stream and the path is the identity of that stream.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #accept(data) ⇒ Object
- #add_state(data) ⇒ Object
- #deleted ⇒ Object
- #eof ⇒ Object
- #error ⇒ Object
-
#initialize(path, input) ⇒ FileListener
constructor
construct with link back to the input plugin instance.
- #opened ⇒ Object
- #process_event(event) ⇒ Object
- #timed_out ⇒ Object
Constructor Details
#initialize(path, input) ⇒ FileListener
construct with link back to the input plugin instance.
10 11 12 13 |
# File 'lib/logstash/inputs/file_listener.rb', line 10 def initialize(path, input) @path, @input = path, input @data = nil end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/logstash/inputs/file_listener.rb', line 8 def data @data end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
8 9 10 |
# File 'lib/logstash/inputs/file_listener.rb', line 8 def input @input end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/logstash/inputs/file_listener.rb', line 8 def path @path end |
Instance Method Details
#accept(data) ⇒ Object
33 34 35 36 37 |
# File 'lib/logstash/inputs/file_listener.rb', line 33 def accept(data) # and push transient data filled dup listener downstream input.log_line_received(path, data) input.codec.accept(dup_adding_state(data)) end |
#add_state(data) ⇒ Object
45 46 47 48 |
# File 'lib/logstash/inputs/file_listener.rb', line 45 def add_state(data) @data = data self end |
#deleted ⇒ Object
28 29 30 31 |
# File 'lib/logstash/inputs/file_listener.rb', line 28 def deleted input.codec.evict(path) input.handle_deletable_path(path) end |
#eof ⇒ Object
18 19 |
# File 'lib/logstash/inputs/file_listener.rb', line 18 def eof end |
#error ⇒ Object
21 22 |
# File 'lib/logstash/inputs/file_listener.rb', line 21 def error end |
#opened ⇒ Object
15 16 |
# File 'lib/logstash/inputs/file_listener.rb', line 15 def opened end |
#process_event(event) ⇒ Object
39 40 41 42 43 |
# File 'lib/logstash/inputs/file_listener.rb', line 39 def process_event(event) event.set("[@metadata][path]", path) event.set("path", path) unless event.include?("path") input.post_process_this(event) end |
#timed_out ⇒ Object
24 25 26 |
# File 'lib/logstash/inputs/file_listener.rb', line 24 def timed_out input.codec.evict(path) end |