Class: Fluent::GenHashValueFilter
- Inherits:
-
Filter
- Object
- Filter
- Fluent::GenHashValueFilter
- Defined in:
- lib/fluent/plugin/filter_genhashvalue.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #filter(tag, time, record) ⇒ Object
- #hash_enc(type, str) ⇒ Object
- #hash_hex(type, str) ⇒ Object
-
#initialize ⇒ GenHashValueFilter
constructor
A new instance of GenHashValueFilter.
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ GenHashValueFilter
Returns a new instance of GenHashValueFilter.
16 17 18 19 20 |
# File 'lib/fluent/plugin/filter_genhashvalue.rb', line 16 def initialize super require 'base64' require 'base91' end |
Instance Method Details
#configure(conf) ⇒ Object
22 23 24 25 |
# File 'lib/fluent/plugin/filter_genhashvalue.rb', line 22 def configure(conf) #$log.trace "configure #{conf}" super end |
#filter(tag, time, record) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fluent/plugin/filter_genhashvalue.rb', line 37 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) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fluent/plugin/filter_genhashvalue.rb', line 64 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) end if base64_enc then h = Base64::strict_encode64(h) elsif base91_enc then h = Base91::encode(h) end end |
#hash_hex(type, str) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fluent/plugin/filter_genhashvalue.rb', line 51 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) end end |
#shutdown ⇒ Object
32 33 34 35 |
# File 'lib/fluent/plugin/filter_genhashvalue.rb', line 32 def shutdown super # destroy end |
#start ⇒ Object
27 28 29 30 |
# File 'lib/fluent/plugin/filter_genhashvalue.rb', line 27 def start super # init end |