module Fluent::SetTimeKeyMixin

Attributes

include_time_key[RW]
localtime[RW]
time_key[RW]
timezone[RW]

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/mixin.rb, line 131
def configure(conf)
  @include_time_key = false

  super

  if s = conf['include_time_key']
    include_time_key = Config.bool_value(s)
    raise ConfigError, "Invalid boolean expression '#{s}' for include_time_key parameter" if include_time_key.nil?

    @include_time_key = include_time_key
  end

  if @include_time_key
    @time_key     = conf['time_key'] || 'time'
    @time_format  = conf['time_format']

    if    conf['localtime']
      @localtime = true
    elsif conf['utc']
      @localtime = false
    end

    if conf['timezone']
      @timezone = conf['timezone']
      Fluent::Timezone.validate!(@timezone)
    end

    @timef = TimeFormatter.new(@time_format, @localtime, @timezone)
  end
end
filter_record(tag, time, record) click to toggle source
Calls superclass method Fluent::RecordFilterMixin#filter_record
# File lib/fluent/mixin.rb, line 162
def filter_record(tag, time, record)
  super

  record[@time_key] = @timef.format(time) if @include_time_key
end