class GroongaQueryLog::Command::Extract::InspectFormatter

Public Class Methods

new(output) click to toggle source
# File lib/groonga-query-log/command/extract.rb, line 203
def initialize(output)
  @output = output
  @first_comand = false
end

Public Instance Methods

command(statistic, command_text) click to toggle source
# File lib/groonga-query-log/command/extract.rb, line 212
def command(statistic, command_text)
  if @first_command
    @first_command = false
  else
    @output.puts(",")
  end
  record = {
    "start_time" => statistic.start_time,
    "elapsed_time" => statistic.elapsed_in_seconds,
    "end_time" => statistic.end_time,
    "return_code" => statistic.return_code,
    "command" => command_text,
  }
  statistic.command.arguments.each do |name, value|
    record["argument_#{name}"] = value
  end
  @output.print(record.to_json)
end
finish() click to toggle source
# File lib/groonga-query-log/command/extract.rb, line 231
def finish
  @output.puts("") unless @first_comand
  @output.puts("]")
end
start() click to toggle source
# File lib/groonga-query-log/command/extract.rb, line 208
def start
  @output.puts("[")
end