lib/fluent/plugin/parser.rb in fluentd-0.14.1 vs lib/fluent/plugin/parser.rb in fluentd-0.14.2
- old
+ new
@@ -95,78 +95,9 @@
end
end
end
end
- class RegexpParser < Parser
- include Fluent::TypeConverter
-
- config_param :time_key, :string, default: 'time'
- config_param :time_format, :string, default: nil
-
- def initialize(regexp, conf={})
- super()
-
- unless conf.empty?
- unless conf.is_a?(Config::Element)
- conf = Config::Element.new('default_regexp_conf', '', conf, [])
- end
- configure(conf)
- end
-
- @regexp = regexp
- @time_parser = TimeParser.new(@time_format)
- @mutex = Mutex.new
- end
-
- def configure(conf)
- super
- @time_parser = TimeParser.new(@time_format)
- end
-
- def patterns
- {'format' => @regexp, 'time_format' => @time_format}
- end
-
- def parse(text)
- m = @regexp.match(text)
- unless m
- yield nil, nil
- return
- end
-
- time = nil
- record = {}
-
- m.names.each do |name|
- if value = m[name]
- if name == @time_key
- time = @mutex.synchronize { @time_parser.parse(value) }
- if @keep_time_key
- record[name] = if @type_converters.nil?
- value
- else
- convert_type(name, value)
- end
- end
- else
- record[name] = if @type_converters.nil?
- value
- else
- convert_type(name, value)
- end
- end
- end
- end
-
- if @estimate_current_event
- time ||= Fluent::EventTime.now
- end
-
- yield time, record
- end
- end
-
class ValuesParser < Parser
include Fluent::TypeConverter
config_param :keys, :array, default: []
config_param :time_key, :string, default: nil