Class: Fluent::TextParser::StdFormatTimeParser

Inherits:
TimeParser
  • Object
show all
Defined in:
lib/fluent/plugin/parser_jsonish.rb

Instance Method Summary collapse

Constructor Details

#initialize(format) ⇒ StdFormatTimeParser

Extend the standard TimeParser to be able to use methods for standard formats – in particular, for formats which can be represented by muliple hard-coded formats. For instance, the iso8601 format can be represented by either of the following formats (probably more) which are not interchangable as arguments to strptime – whether or not the tiemstamp has millisecond precision must be treated as two distinct formats if the available iso8601 method is not used:

  • ‘%y-%m-%dT%H:%M:%S%Z’ (no fractional seconds)

  • ‘%y-%m-%dT%H:%M:%S.%L%Z’ (fractional seconds)



17
18
19
20
21
22
23
24
25
# File 'lib/fluent/plugin/parser_jsonish.rb', line 17

def initialize(format)

  if not /%/.match(format)
    super()
    @parse = ->(v){ Fluent::EventTime.from_time(Time.method(format).call(v)) }
  else
    super(format)
  end
end