Module: Fluent::TimeMixin::TimeParameters

Includes:
Configurable
Defined in:
lib/fluent/time.rb

Constant Summary

Constants included from Configurable

Configurable::CONFIG_TYPE_REGISTRY

Instance Method Summary collapse

Methods included from Configurable

#config, #configure_proxy_generate, #configured_section_create, included, #initialize, lookup_type, register_type

Instance Method Details

#configure(conf) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/fluent/time.rb', line 155

def configure(conf)
  if conf.has_key?('localtime') || conf.has_key?('utc')
    if conf.has_key?('localtime')
      conf['localtime'] = Fluent::Config.bool_value(conf['localtime'])
    elsif conf.has_key?('utc')
      conf['localtime'] = !(Fluent::Config.bool_value(conf['utc']))
      # Specifying "localtime false" means using UTC in TimeFormatter
      # And specifying "utc" is different from specifying "timezone +0000"(it's not always UTC).
      # There are difference between "Z" and "+0000" in timezone formatting.
      # TODO: add kwargs to TimeFormatter to specify "using localtime", "using UTC" or "using specified timezone" in more explicit way
    end
  end

  super

  if conf.has_key?('localtime') && conf.has_key?('utc') && !(@localtime ^ @utc)
    raise Fluent::ConfigError, "both of utc and localtime are specified, use only one of them"
  end

  if conf.has_key?('time_type') and @time_type == :mixed
    if @time_format.nil? and @time_format_fallbacks.empty?
      raise Fluent::ConfigError, "time_type is :mixed but time_format and time_format_fallbacks is empty."
    end
  end

  Fluent::Timezone.validate!(@timezone) if @timezone
end