Class: LogStash::Inputs::Gunzip
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::Gunzip
- Defined in:
- lib/logstash/inputs/gunzip.rb
Overview
This plugin decompress gzip input file
Instance Method Summary collapse
- #register ⇒ Object
-
#run(queue) ⇒ Object
def register.
-
#stop ⇒ Object
Close file.
Instance Method Details
#register ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/logstash/inputs/gunzip.rb', line 33 def register @host = Socket.gethostname @gzstream = {} @path.each do |path| @logger.info("Opening file", :path => path) @gzstream[path] = Zlib::GzipReader.new(open(path), {"encoding"=>@codec.charset}) end end |
#run(queue) ⇒ Object
def register
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/logstash/inputs/gunzip.rb', line 42 def run(queue) @path.each do |path| lineNumber = 0 @gzstream[path].each_line do |line| lineNumber = lineNumber+1 @codec.decode(line) do |event| decorate(event) event.set("host", @hostname) if !event.include?("host") event.set("path", path) event.set("line_number", lineNumber) queue << event end end end end |
#stop ⇒ Object
Close file
60 61 62 63 64 |
# File 'lib/logstash/inputs/gunzip.rb', line 60 def stop @path.each do |path| @gzstream[path].close end end |