lib/dexter/log_parser.rb in pgdexter-0.4.2 vs lib/dexter/log_parser.rb in pgdexter-0.4.3
- old
+ new
@@ -4,36 +4,14 @@
REGEX = /duration: (\d+\.\d+) ms (statement|execute [^:]+): (.+)/
LINE_SEPERATOR = ": ".freeze
DETAIL_LINE = "DETAIL: ".freeze
+ attr_accessor :once
+
def initialize(logfile, collector)
@logfile = logfile
@collector = collector
- end
-
- def perform
- active_line = nil
- duration = nil
-
- @logfile.each_line do |line|
- if active_line
- if line.include?(DETAIL_LINE)
- add_parameters(active_line, line.chomp.split(DETAIL_LINE)[1])
- elsif line.include?(LINE_SEPERATOR)
- process_entry(active_line, duration)
- active_line = nil
- else
- active_line << line
- end
- end
-
- if !active_line && (m = REGEX.match(line.chomp))
- duration = m[1].to_f
- active_line = m[3]
- end
- end
- process_entry(active_line, duration) if active_line
end
private
def process_entry(query, duration)