🏡 index : ~doyle/logstash-codec-gzip.git

Diff

 logstash-codec-gzip.gemspec | 4 ++--
 lib/logstash/codecs/gzip.rb | 8 ++++++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/logstash-codec-gzip.gemspec b/logstash-codec-gzip.gemspec
index 209d425..75a3bbc 100644
--- a/logstash-codec-gzip.gemspec
+++ a/logstash-codec-gzip.gemspec
@@ -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" }

  # Gem dependencies
  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
diff --git a/lib/logstash/codecs/gzip.rb b/lib/logstash/codecs/gzip.rb
index 90c01fd..9ee4cf8 100644
--- a/lib/logstash/codecs/gzip.rb
+++ a/lib/logstash/codecs/gzip.rb
@@ -23,6 +23,8 @@
  # For nxlog users, you may to set this to "CP1252".
  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 # def decode
end # class LogStash::Codecs::JSON