Class: GroongaQueryLog::Command::Analyzer::ConsoleReporter

Inherits:
Reporter
  • Object
show all
Defined in:
lib/groonga-query-log/command/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

#initialize(statistics, options) ⇒ ConsoleReporter

Returns a new instance of ConsoleReporter.



125
126
127
128
129
130
131
132
133
134
135
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 125

def initialize(statistics, options)
  super
  @color = @options[:color]
  @color = :auto if @color.nil?
  @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

#finishObject



159
160
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 159

def finish
end

#report_statistic(statistic) ⇒ Object



143
144
145
146
147
148
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 143

def report_statistic(statistic)
  @index += 1
  write("%*d) %s\n" % [@digit, @index, format_heading(statistic)])
  report_parameters(statistic)
  report_operations(statistic)
end

#report_statisticsObject



137
138
139
140
141
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 137

def report_statistics
  write("\n")
  write("Slow Queries:\n")
  super
end

#startObject



150
151
152
153
154
155
156
157
# File 'lib/groonga-query-log/command/analyzer/reporter/console.rb', line 150

def start
  @index = 0
  if @statistics.size.zero?
    @digit = 1
  else
    @digit = Math.log10(@statistics.size).truncate + 1
  end
end