Sha256: 33b066032d196d99fb467256971469433ba25bd5813603667ceaddb64eabee53

Contents?: true

Size: 705 Bytes

Versions: 6

Compression:

Stored size: 705 Bytes

Contents

module Dexter
  class LogParser
    include Logging

    REGEX = /duration: (\d+\.\d+) ms  (statement|execute [^:]+): (.+)/

    def initialize(logfile, collector)
      @logfile = logfile
      @collector = collector
    end

    private

    def process_entry(query, duration)
      @collector.add(query, duration)
    end

    def add_parameters(active_line, details)
      if details.start_with?("parameters: ")
        params = Hash[details[12..-1].split(", ").map { |s| s.split(" = ", 2) }]

        # make sure parsing was successful
        unless params.values.include?(nil)
          params.each do |k, v|
            active_line.sub!(k, v)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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