Support newer versions of the Logstash plugin API
Diff
logstash-codec-gzip.gemspec | 4 ++--
lib/logstash/codecs/gzip.rb | 8 ++++++--
2 files changed, 7 insertions(+), 5 deletions(-)
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'logstash-codec-gzip'
s.version = '2.0.4'
s.version = '3.0.0'
s.licenses = ['Apache License (2.0)']
s.summary = "This codec may be used to decode (via inputs) and encode (via outputs) full gzip messages"
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -20,7 +20,7 @@
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "codec" }
s.add_runtime_dependency "logstash-core", "< 2.0.0"
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
s.add_development_dependency 'logstash-devutils'
end
@@ -23,6 +23,8 @@
config :charset, :validate => ::Encoding.name_list, :default => "UTF-8"
MESSAGE_FIELD = "message".freeze
public
def register
@converter = LogStash::Util::Charset.new(@charset)
@@ -33,10 +35,10 @@
def decode(data)
begin
decoded = Zlib::GzipReader.new(StringIO.new(data)).read
yield LogStash::Event.new("message" => @converter.convert(decoded))
yield LogStash::Event.new(MESSAGE_FIELD => @converter.convert(decoded))
rescue Zlib::Error, Zlib::GzipFile::Error=> e
@logger.info? && @logger.info("GZIP parse failure. Falling back to plain-text", :error => e, :data => data)
yield LogStash::Event.new("message" => data, "tags" => ["_gzipparsefailure"])
@logger.info? && @logger.info("Gzip codec: GZIP parse failure. Falling back to plain-text", :error => e, :data => data)
yield LogStash::Event.new(MESSAGE_FIELD => @converter.convert(data), "tags" => ["_gzipparsefailure"])
end
end
end