Module: FluentdRegexpTester
- Defined in:
- lib/fluentd_regexp_tester/cli.rb,
lib/fluentd_regexp_tester/parse.rb,
lib/fluentd_regexp_tester/version.rb
Defined Under Namespace
Classes: CLI
Constant Summary collapse
- VERSION =
"0.1.4"
Class Method Summary collapse
Class Method Details
.parse(input, regexp, time_format = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fluentd_regexp_tester/parse.rb', line 6 def self.parse(input, regexp, time_format = nil) parsed_time = nil parsed = nil error = nil conf = {} if !time_format.nil? conf['time_format'] = time_format end begin regexp = Regexp.new(regexp.gsub(%r{^\/(.+)\/$}, '\1')) parser = Fluent::Compat::TextParser::RegexpParser.new(regexp) parser.configure(Fluent::Config::Element.new('', '', conf, [])) parser.parse(input) do |pt, p| parsed_time = pt parsed = p end rescue Fluent::Plugin::Parser::ParserError, RegexpError => e error = e end [error, parsed, parsed_time] end |