Module: Fluent::SetTimeKeyMixin
- Includes:
- RecordFilterMixin
- Defined in:
- lib/fluent/mixin.rb
Instance Attribute Summary collapse
-
#include_time_key ⇒ Object
Returns the value of attribute include_time_key.
-
#localtime ⇒ Object
Returns the value of attribute localtime.
-
#time_key ⇒ Object
Returns the value of attribute time_key.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
Instance Method Summary collapse
Methods included from RecordFilterMixin
Instance Attribute Details
#include_time_key ⇒ Object
Returns the value of attribute include_time_key.
129 130 131 |
# File 'lib/fluent/mixin.rb', line 129 def include_time_key @include_time_key end |
#localtime ⇒ Object
Returns the value of attribute localtime.
129 130 131 |
# File 'lib/fluent/mixin.rb', line 129 def localtime @localtime end |
#time_key ⇒ Object
Returns the value of attribute time_key.
129 130 131 |
# File 'lib/fluent/mixin.rb', line 129 def time_key @time_key end |
#timezone ⇒ Object
Returns the value of attribute timezone.
129 130 131 |
# File 'lib/fluent/mixin.rb', line 129 def timezone @timezone end |
Instance Method Details
#configure(conf) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# 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) ⇒ Object
162 163 164 165 166 |
# 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 |