Class: FluentExt::TextParser::RegexpParser
- Inherits:
-
Object
- Object
- FluentExt::TextParser::RegexpParser
- Includes:
- Fluent::Configurable
- Defined in:
- lib/fluent/plugin/fixed_parser.rb
Instance Method Summary collapse
- #call(text) ⇒ Object
-
#initialize(regexp, conf = {}) ⇒ RegexpParser
constructor
A new instance of RegexpParser.
Constructor Details
#initialize(regexp, conf = {}) ⇒ RegexpParser
Returns a new instance of RegexpParser.
12 13 14 15 16 17 18 |
# File 'lib/fluent/plugin/fixed_parser.rb', line 12 def initialize(regexp, conf={}) super() @regexp = regexp unless conf.empty? configure(conf) end end |
Instance Method Details
#call(text) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fluent/plugin/fixed_parser.rb', line 20 def call(text) m = @regexp.match(text) unless m $log.debug "pattern not match: #{text}" # TODO? return nil, nil end time = nil record = {} m.names.each {|name| if value = m[name] case name when "time" if @time_format time = Time.strptime(value, @time_format).to_i else time = Time.parse(value).to_i end else record[name] = value end end } return time, record end |