Kouhei Sutou
null+****@clear*****
Wed Jul 23 13:16:01 JST 2014
Kouhei Sutou 2014-07-23 13:16:01 +0900 (Wed, 23 Jul 2014) New Revision: f1b89f1b7b26d9c0f4a88741e92d4d5b2c5a6969 https://github.com/groonga/groonga-query-log/commit/f1b89f1b7b26d9c0f4a88741e92d4d5b2c5a6969 Message: analyzer: add json-stream reporter Added files: lib/groonga/query-log/analyzer/reporter/json-stream.rb Modified files: lib/groonga/query-log/analyzer.rb Modified: lib/groonga/query-log/analyzer.rb (+4 -1) =================================================================== --- lib/groonga/query-log/analyzer.rb 2014-07-23 13:15:33 +0900 (a1c2dc3) +++ lib/groonga/query-log/analyzer.rb 2014-07-23 13:16:01 +0900 (3b86c96) @@ -26,6 +26,7 @@ require "groonga/query-log/analyzer/sized-statistics" require "groonga/query-log/analyzer/reporter/console" require "groonga/query-log/analyzer/reporter/html" require "groonga/query-log/analyzer/reporter/json" +require "groonga/query-log/analyzer/reporter/json-stream" module Groonga module QueryLog @@ -178,7 +179,7 @@ module Groonga @options[:slow_response_threshold] = threshold end - available_reporters = ["console", "json", "html"] + available_reporters = ["console", "json", "json-stream", "html"] parser.on("--reporter=REPORTER", available_reporters, "Reports statistics by REPORTER.", @@ -213,6 +214,8 @@ module Groonga case @options[:reporter] when "json" JSONReporter.new(statistics) + when "json-stream" + JSONStreamReporter.new(statistics) when "html" HTMLReporter.new(statistics) else Added: lib/groonga/query-log/analyzer/reporter/json-stream.rb (+49 -0) 100644 =================================================================== --- /dev/null +++ lib/groonga/query-log/analyzer/reporter/json-stream.rb 2014-07-23 13:16:01 +0900 (5c0273b) @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2014 Kouhei Sutou <kou �� clear-code.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "groonga/query-log/analyzer/reporter" + +module Groonga + module QueryLog + class Analyzer + class JSONStreamReporter < Reporter + def report_statistic(statistic) + write(format_statistic(statistic)) + write("\n") + @index += 1 + end + + def start + @index = 0 + end + + def finish + end + + def report_summary + # TODO + end + + private + def format_statistic(statistic) + JSON.pretty_generate(statistic.to_hash) + end + end + end + end +end -------------- next part -------------- HTML����������������������������...Download