Sha256: d8746c6be35cb7ab2238629a5d03e7a94a58b036ae204da87c9c89a77466213e
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
# encoding: utf-8 require "i18n" require "logstash/filters/base" require "logstash/namespace" # The i18n filter allows you to remove special characters # from a field class LogStash::Filters::I18n < LogStash::Filters::Base config_name "i18n" milestone 0 # Replaces non-ASCII characters with an ASCII approximation, or # if none exists, a replacement character which defaults to `?` # # Example: # [source,ruby] # filter { # i18n { # transliterate => ["field1", "field2"] # } # } config :transliterate, :validate => :array public def register end # def register public def filter(event) transliterate(event) if @transliterate filter_matched(event) end # def filter private def transliterate(event) @transliterate.each do |field| if event[field].is_a?(Array) event[field].map! { |v| I18n.transliterate(v).encode('UTF-8') } elsif event[field].is_a?(String) event[field] = I18n.transliterate(event[field].encode('UTF-8')) else @logger.debug("Can't transliterate something that isn't a string", :field => field, :value => event[field]) end end end # def transliterate end # class LogStash::Filters::I18n
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
logstash-filter-i18n-2.0.4 | lib/logstash/filters/i18n.rb |
logstash-filter-i18n-2.0.2 | lib/logstash/filters/i18n.rb |
logstash-filter-i18n-2.0.1 | lib/logstash/filters/i18n.rb |