Module: Fluent::TextFormatter::HandleTagAndTimeMixin

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fluent/formatter.rb', line 36

def self.included(klass)
  klass.instance_eval {
    config_param :include_time_key, :bool, default: false
    config_param :time_key, :string, default: 'time'
    config_param :time_format, :string, default: nil
    config_param :include_tag_key, :bool, default: false
    config_param :tag_key, :string, default: 'tag'
    config_param :localtime, :bool, default: true
    config_param :timezone, :string, default: nil
  }
end

Instance Method Details

#configure(conf) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/fluent/formatter.rb', line 48

def configure(conf)
  super

  if conf['utc']
    @localtime = false
  end
  @timef = TimeFormatter.new(@time_format, @localtime, @timezone)
end

#filter_record(tag, time, record) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/fluent/formatter.rb', line 57

def filter_record(tag, time, record)
  if @include_tag_key
    record[@tag_key] = tag
  end
  if @include_time_key
    record[@time_key] = @timef.format(time)
  end
end