class Fluent::Plugin::TextParser::MonologParser

Constants

REGEXP
TIME_FORMAT

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/fluent/plugin/parser_monolog.rb, line 13
def initialize
  super
  @time_parser = TimeParser.new(TIME_FORMAT)
  @mutex = Mutex.new
end

Public Instance Methods

parse(text) { |nil, nil| ... } click to toggle source
# File lib/fluent/plugin/parser_monolog.rb, line 23
def parse(text)
  m = REGEXP.match(text)
  unless m
    yield nil, nil
    return
  end

  time = m['time']
  time = @mutex.synchronize { @time_parser.parse(time) }

  channel = m['channel']
  level = m['level']
  message = m['message']
  context = JSON.parse(m['context'])
  extra = JSON.parse(m['extra'])

  record = {
      "channel" => channel,
      "level" => level,
      "message" => message,
      "context" => context,
      "extra" => extra
  }
  record["time"] = m['time'] if @keep_time_key

  yield time, record
end
patterns() click to toggle source
# File lib/fluent/plugin/parser_monolog.rb, line 19
def patterns
  {'format' => REGEXP, 'time_format' => TIME_FORMAT}
end