Class: Groonga::QueryLog::Analyzer::ConsoleReporter
- Inherits:
-
Reporter
- Object
- Reporter
- Groonga::QueryLog::Analyzer::ConsoleReporter
show all
- Defined in:
- lib/groonga/query-log/analyzer/reporter/console.rb
Defined Under Namespace
Classes: Color, MixColor
Instance Attribute Summary
Attributes inherited from Reporter
#output, #slow_operation_threshold, #slow_response_threshold
Instance Method Summary
collapse
Methods inherited from Reporter
#each, #report
Constructor Details
Returns a new instance of ConsoleReporter.
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/groonga/query-log/analyzer/reporter/console.rb', line 127
def initialize(statistics)
super
@color = :auto
@reset_color = Color.new("reset")
@color_schema = {
:elapsed => {:foreground => :white, :background => :green},
:time => {:foreground => :white, :background => :cyan},
:slow => {:foreground => :white, :background => :red},
}
end
|
Instance Method Details
#apply_options(options) ⇒ Object
138
139
140
141
|
# File 'lib/groonga/query-log/analyzer/reporter/console.rb', line 138
def apply_options(options)
super
@color = options[:color] || @color
end
|
#finish ⇒ Object
165
166
|
# File 'lib/groonga/query-log/analyzer/reporter/console.rb', line 165
def finish
end
|
#report_statistic(statistic) ⇒ Object
149
150
151
152
153
154
|
# File 'lib/groonga/query-log/analyzer/reporter/console.rb', line 149
def report_statistic(statistic)
@index += 1
write("%*d) %s" % [@digit, @index, format_heading(statistic)])
report_parameters(statistic)
report_operations(statistic)
end
|
#report_statistics ⇒ Object
143
144
145
146
147
|
# File 'lib/groonga/query-log/analyzer/reporter/console.rb', line 143
def report_statistics
write("\n")
write("Slow Queries:\n")
super
end
|
#start ⇒ Object
156
157
158
159
160
161
162
163
|
# File 'lib/groonga/query-log/analyzer/reporter/console.rb', line 156
def start
@index = 0
if @statistics.size.zero?
@digit = 1
else
@digit = Math.log10(@statistics.size).truncate + 1
end
end
|