Class: Fluent::Plugin::LabeledTSVParser

Inherits:
ValuesParser show all
Defined in:
lib/fluent/plugin/parser_ltsv.rb

Direct Known Subclasses

Compat::TextParser::LabeledTSVParser

Constant Summary

Constants included from Compat::TypeConverter

Compat::TypeConverter::Converters

Constants inherited from Parser

Parser::TimeParser

Constants included from Configurable

Configurable::CONFIG_TYPE_REGISTRY

Instance Attribute Summary

Attributes inherited from Parser

#estimate_current_event

Attributes inherited from Base

#under_plugin_development

Instance Method Summary collapse

Methods inherited from ValuesParser

#values_map

Methods included from Compat::TypeConverter

included

Methods inherited from Parser

#call, #initialize

Methods included from TimeMixin::Parser

included, #time_parser_create

Methods included from OwnedByMixin

#log, #owner, #owner=

Methods inherited from Base

#after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #close, #closed?, #configured?, #has_router?, #initialize, #inspect, #shutdown, #shutdown?, #start, #started?, #stop, #stopped?, #terminate, #terminated?

Methods included from SystemConfig::Mixin

#system_config, #system_config_override

Methods included from Configurable

#config, included, #initialize, lookup_type, register_type

Constructor Details

This class inherits a constructor from Fluent::Plugin::Parser

Instance Method Details

#configure(conf) ⇒ Object



29
30
31
32
33
# File 'lib/fluent/plugin/parser_ltsv.rb', line 29

def configure(conf)
  # this assignment is not to raise ConfigError in ValuesParser#configure
  conf['keys'] = conf['time_key'] || 'time'
  super(conf)
end

#parse(text) {|values_map(values)| ... } ⇒ Object

Yields:



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

def parse(text)
  # TODO: thread unsafe: @keys might be changed by other threads
  @keys  = []
  values = []

  text.split(delimiter).each do |pair|
    key, value = pair.split(label_delimiter, 2)
    @keys.push(key)
    values.push(value)
  end

  yield values_map(values)
end