Class: Groonga::QueryLog::Analyzer::ConsoleReporter

Inherits:
Reporter
  • Object
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

Instance Method Summary collapse

Methods inherited from Reporter

#each, #report

Constructor Details

#initialize(statistics) ⇒ ConsoleReporter

Returns a new instance of ConsoleReporter.



119
120
121
122
123
124
125
126
127
128
# File 'lib/groonga/query-log/analyzer/reporter/console.rb', line 119

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



130
131
132
133
# File 'lib/groonga/query-log/analyzer/reporter/console.rb', line 130

def apply_options(options)
  super
  @color = options[:color] || @color
end

#finishObject



157
158
# File 'lib/groonga/query-log/analyzer/reporter/console.rb', line 157

def finish
end

#report_statistic(statistic) ⇒ Object



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

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

#report_statisticsObject



135
136
137
138
139
# File 'lib/groonga/query-log/analyzer/reporter/console.rb', line 135

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

#startObject



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

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