Class: Fluent::FileSprintfOutput
- Inherits:
-
TimeSlicedOutput
- Object
- TimeSlicedOutput
- Fluent::FileSprintfOutput
- Defined in:
- lib/fluent/plugin/out_file_sprintf.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ FileSprintfOutput
constructor
A new instance of FileSprintfOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ FileSprintfOutput
Returns a new instance of FileSprintfOutput.
18 19 20 21 22 23 |
# File 'lib/fluent/plugin/out_file_sprintf.rb', line 18 def initialize super require 'zlib' require 'ltsv' require 'set' end |
Instance Method Details
#configure(conf) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fluent/plugin/out_file_sprintf.rb', line 33 def configure(conf) super @key_names = @key_names.split(',').map{|key| key = key.strip result = "" if key == 'time' result = "Time.at(time).strftime('#{@time_format}')" elsif key == 'tag' result = 'tag' elsif key == 'ltsv' result = 'LTSV.dump(record)' elsif key == 'json' result = 'record.to_json' elsif key == 'msgpack' result = 'record.to_msgpack' else result = "record['" + key + "']" end result } @key_names = @key_names.join(',') @eval_string = "%Q{#{@format}} % [#{@key_names}]" $log.info "format => #{@eval_string}" $log.info "flush_interval => #{@flush_interval}" end |
#format(tag, time, record) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/fluent/plugin/out_file_sprintf.rb', line 59 def format(tag, time, record) if @include_tag_key record[@tag_key_name] = tag end if @include_time_key record[@time_key_name] = Time.at(time).strftime(@time_format) end [tag, time, record].to_msgpack end |
#shutdown ⇒ Object
29 30 31 |
# File 'lib/fluent/plugin/out_file_sprintf.rb', line 29 def shutdown super end |
#start ⇒ Object
25 26 27 |
# File 'lib/fluent/plugin/out_file_sprintf.rb', line 25 def start super end |
#write(chunk) ⇒ Object
69 70 71 72 |
# File 'lib/fluent/plugin/out_file_sprintf.rb', line 69 def write(chunk) write_file(chunk) compress_file end |