Sha256: aff1754780c3ef5fb1b6c540a1dd80f3b1bab41f5311a0bcfa3a32d47bcfcd37

Contents?: true

Size: 604 Bytes

Versions: 7

Compression:

Stored size: 604 Bytes

Contents

module Dexter
  class JsonLogParser < LogParser
    FIRST_LINE_REGEX = /\A.+/

    def perform
      @logfile.each_line do |line|
        row = JSON.parse(line.chomp)
        if (m = REGEX.match(row["message"]))
          # replace first line with match
          # needed for multiline queries
          active_line = row["message"].sub(FIRST_LINE_REGEX, m[3])

          add_parameters(active_line, row["detail"]) if row["detail"]
          process_entry(active_line, m[1].to_f)
        end
      end
    rescue JSON::ParserError => e
      raise Dexter::Abort, "ERROR: #{e.message}"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pgdexter-0.5.5 lib/dexter/json_log_parser.rb
pgdexter-0.5.4 lib/dexter/json_log_parser.rb
pgdexter-0.5.3 lib/dexter/json_log_parser.rb
pgdexter-0.5.2 lib/dexter/json_log_parser.rb
pgdexter-0.5.1 lib/dexter/json_log_parser.rb
pgdexter-0.5.0 lib/dexter/json_log_parser.rb
pgdexter-0.4.3 lib/dexter/json_log_parser.rb