Class: Fluent::Plugin::RegexpParser
- Defined in:
- lib/fluent/plugin/parser_regexp.rb
Direct Known Subclasses
Compat::TextParser::RegexpParser, ApacheErrorParser, ApacheParser, NginxParser
Constant Summary
Constants inherited from Parser
Parser::AVAILABLE_PARSER_VALUE_TYPES, Parser::PARSER_TYPES, Parser::TRUTHY_VALUES
Constants included from Configurable
Configurable::CONFIG_TYPE_REGISTRY
Instance Attribute Summary
Attributes inherited from Parser
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Parser
#build_type_converters, #call, #convert_values, #implement?, #parse_io, #parse_partial_data, #parse_time, #parser_type, #string_like_null
Methods included from TimeMixin::Parser
Methods included from OwnedByMixin
Methods inherited from Base
#after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #close, #closed?, #configured?, #context_router, #context_router=, #fluentd_worker_id, #has_router?, #initialize, #inspect, #multi_workers_ready?, #plugin_root_dir, #shutdown, #shutdown?, #start, #started?, #stop, #stopped?, #string_safe_encoding, #terminate, #terminated?
Methods included from SystemConfig::Mixin
#system_config, #system_config_override
Methods included from Configurable
#config, #configure_proxy_generate, #configured_section_create, included, #initialize, lookup_type, register_type
Constructor Details
This class inherits a constructor from Fluent::Plugin::Base
Instance Method Details
#configure(conf) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fluent/plugin/parser_regexp.rb', line 30 def configure(conf) super expr = if @expression[0] == "/" && @expression[-1] == "/" @expression[1..-2] else @expression end regexp_option = 0 regexp_option |= Regexp::IGNORECASE if @ignorecase regexp_option |= Regexp::MULTILINE if @multiline @regexp = Regexp.new(expr, regexp_option) end |
#parse(text) {|time, record| ... } ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fluent/plugin/parser_regexp.rb', line 44 def parse(text) m = @regexp.match(text) unless m yield nil, nil return end r = {} m.names.each do |name| if value = m[name] r[name] = value end end time, record = convert_values(parse_time(r), r) yield time, record end |