Class: Fluent::ParseCookieOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::ParseCookieOutput
- Defined in:
- lib/fluent/plugin/out_parse_cookie.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
-
#initialize ⇒ ParseCookieOutput
constructor
A new instance of ParseCookieOutput.
- #parse_cookie(record) ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ ParseCookieOutput
Returns a new instance of ParseCookieOutput.
11 12 13 14 |
# File 'lib/fluent/plugin/out_parse_cookie.rb', line 11 def initialize super require 'cgi' end |
Instance Method Details
#configure(conf) ⇒ Object
21 22 23 |
# File 'lib/fluent/plugin/out_parse_cookie.rb', line 21 def configure(conf) super end |
#emit(tag, es, chain) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fluent/plugin/out_parse_cookie.rb', line 33 def emit(tag, es, chain) es.each {|time, record| t = tag.dup new_record = (record) t = @tag_prefix + t unless @tag_prefix.nil? Engine.emit(t, time, new_record) } chain.next rescue => e log.warn("out_parse_cookie: error_class:#{e.class} error_message:#{e.} tag:#{tag} es:#{es} bactrace:#{e.backtrace.first}") end |
#parse_cookie(record) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fluent/plugin/out_parse_cookie.rb', line 47 def (record) if record[key] = CGI::Cookie.parse(record[key]) hash = {} .each do |k,array| hash.merge!({k => array.select {|v| v.class == String }}) end hash = hash.select {|k, v| v != []} if remove_empty_array == true if single_value_to_string == true hash.each do |k, v| if v.count == 1 hash[k] = v[0] end end end target = sub_key ? (record[sub_key] ||= {}) : record target.merge!(hash) record.delete(key) if end return record rescue => e log.warn("out_parse_cookie: error_class:#{e.class} error_message:#{e.} tag:#{tag} record:#{record} bactrace:#{e.backtrace.first}") end |
#shutdown ⇒ Object
29 30 31 |
# File 'lib/fluent/plugin/out_parse_cookie.rb', line 29 def shutdown super end |
#start ⇒ Object
25 26 27 |
# File 'lib/fluent/plugin/out_parse_cookie.rb', line 25 def start super end |