lib/request_log_analyzer/aggregator/summarizer.rb in wvanbergen-request-log-analyzer-1.1.2 vs lib/request_log_analyzer/aggregator/summarizer.rb in wvanbergen-request-log-analyzer-1.1.3
- old
+ new
@@ -1,7 +1,5 @@
-require File.dirname(__FILE__) + '/../tracker'
-
module RequestLogAnalyzer::Aggregator
class Summarizer < Base
class Definer
@@ -9,10 +7,14 @@
attr_reader :trackers
def initialize
@trackers = []
end
+
+ def initialize_copy(other)
+ @trackers = other.trackers.dup
+ end
def reset!
@trackers = []
end
@@ -56,11 +58,11 @@
end
def prepare
raise "No trackers set up in Summarizer!" if @trackers.nil? || @trackers.empty?
@trackers.each { |tracker| tracker.prepare }
- end
+ end
def aggregate(request)
@trackers.each do |tracker|
tracker.update(request) if tracker.should_update?(request)
end
@@ -84,37 +86,37 @@
def report_header(output)
output.title("Request summary")
output.with_style(:cell_separator => false) do
output.table({:width => 20}, {:font => :bold}) do |rows|
- rows << ['Parsed lines:', source.parsed_lines]
- rows << ['Parsed request:', source.parsed_requests]
- rows << ['Skipped lines:', source.skipped_lines]
+ rows << ['Parsed lines:', source.parsed_lines]
+ rows << ['Parsed requests:', source.parsed_requests]
+ rows << ['Skipped lines:', source.skipped_lines]
- rows << ["Warnings:", @warnings_encountered.map { |(key, value)| "#{key.inspect}: #{value}" }.join(', ')] if has_warnings?
+ rows << ["Warnings:", @warnings_encountered.map { |(key, value)| "#{key}: #{value}" }.join(', ')] if has_warnings?
end
end
output << "\n"
end
def report_footer(output)
- if has_serious_warnings?
-
+ if has_log_ordering_warnings?
output.title("Parse warnings")
- output.puts "Multiple warnings were encountered during parsing. Possibly, your logging "
- output.puts "is not setup correctly. Visit this website for logging configuration tips:"
+ output.puts "Parseable lines were ancountered without a header line before it. It"
+ output.puts "could be that logging is not setup correctly for your application."
+ output.puts "Visit this website for logging configuration tips:"
output.puts output.link("http://github.com/wvanbergen/request-log-analyzer/wikis/configure-logging")
output.puts
end
end
def has_warnings?
@warnings_encountered.inject(0) { |result, (key, value)| result += value } > 0
end
- def has_serious_warnings?
- @warnings_encountered.inject(0) { |result, (key, value)| result += value } > 10
+ def has_log_ordering_warnings?
+ @warnings_encountered[:no_current_request] && @warnings_encountered[:no_current_request] > 0
end
def warning(type, message, lineno)
@warnings_encountered[type] ||= 0
@warnings_encountered[type] += 1