class Fluent::Plugin::GenHashValueFilter
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_genhashvalue.rb, line 19 def initialize super require 'base64' require 'base91' end
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_genhashvalue.rb, line 25 def configure(conf) #$log.trace "configure #{conf}" super end
filter(tag, time, record)
click to toggle source
# File lib/fluent/plugin/filter_genhashvalue.rb, line 40 def filter(tag, time, record) s = "" s += tag + separator if inc_tag_as_key s += time.to_s + separator if inc_time_as_key s += keys.map {|k| record[k]}.join(separator) if base64_enc || base91_enc then record[set_key] = hash_enc(hash_type, s) else record[set_key] = hash_hex(hash_type, s) end record end
hash_enc(type, str)
click to toggle source
# File lib/fluent/plugin/filter_genhashvalue.rb, line 69 def hash_enc(type, str) case type when 'md5' h = Digest::MD5.digest(str) when 'sha1' h = Digest::SHA1.digest(str) when 'sha256' h = Digest::SHA256.digest(str) when 'sha512' h = Digest::SHA512.digest(str) when 'mur128' h = MurmurHash3::V128.str_digest(str) end if base64_enc then h = Base64::strict_encode64(h) elsif base91_enc then h = Base91::encode(h) end end
hash_hex(type, str)
click to toggle source
# File lib/fluent/plugin/filter_genhashvalue.rb, line 54 def hash_hex(type, str) case type when 'md5' h = Digest::MD5.hexdigest(str) when 'sha1' h = Digest::SHA1.hexdigest(str) when 'sha256' h = Digest::SHA256.hexdigest(str) when 'sha512' h = Digest::SHA512.hexdigest(str) when 'mur128' h = MurmurHash3::V128.str_hexdigest(str) end end
shutdown()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_genhashvalue.rb, line 35 def shutdown super # destroy end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_genhashvalue.rb, line 30 def start super # init end