Kouhei Sutou
null+****@clear*****
Mon Dec 11 09:46:19 JST 2017
Kouhei Sutou 2017-12-11 09:46:19 +0900 (Mon, 11 Dec 2017) New Revision: 9d041621fbef7b6ce9675733c17ed06c405359ca https://github.com/groonga/groonga-query-log/commit/9d041621fbef7b6ce9675733c17ed06c405359ca Message: Support extra information by ": ..." Modified files: lib/groonga-query-log/parser.rb lib/groonga-query-log/statistic.rb test/test-parser.rb Modified: lib/groonga-query-log/parser.rb (+4 -2) =================================================================== --- lib/groonga-query-log/parser.rb 2017-12-11 09:41:53 +0900 (07b7af9) +++ lib/groonga-query-log/parser.rb 2017-12-11 09:46:19 +0900 (5aea457) @@ -83,16 +83,18 @@ module GroongaQueryLog statistic.start(time_stamp, rest) @parsing_statistics[context_id] = statistic when ":" - return unless /\A(\d+) (.+)\((\d+)\)(\[.+\])?/ =~ rest + return unless /\A(\d+) (.+)\((\d+)\)(\[.+\])?(?:: (.*))?/ =~ rest elapsed = $1 name = $2 name += $4 if $4 n_records = $3.to_i + extra = $5 statistic = @parsing_statistics[context_id] return if statistic.nil? statistic.add_operation(:name => name, :elapsed => elapsed.to_i, - :n_records => n_records) + :n_records => n_records, + :extra => extra) when "<" return unless /\A(\d+) rc=(-?\d+)/ =~ rest elapsed = $1 Modified: lib/groonga-query-log/statistic.rb (+2 -1) =================================================================== --- lib/groonga-query-log/statistic.rb 2017-12-11 09:41:53 +0900 (58ec736) +++ lib/groonga-query-log/statistic.rb 2017-12-11 09:46:19 +0900 (f0916e6) @@ -93,8 +93,9 @@ module GroongaQueryLog :relative_elapsed_in_seconds => relative_elapsed_in_seconds, :name => operation[:name], :context => operation_context(operation[:name], - operation_context_context), + operation_context_context), :n_records => operation[:n_records], + :extra => operation[:extra], :slow? => slow_operation?(relative_elapsed_in_seconds), } yield parsed_operation Modified: test/test-parser.rb (+18 -3) =================================================================== --- test/test-parser.rb 2017-12-11 09:41:53 +0900 (39f70dd) +++ test/test-parser.rb 2017-12-11 09:46:19 +0900 (9e63862) @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2011-2013 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2011-2017 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 @@ -257,4 +255,21 @@ class ParserTest < Test::Unit::TestCase end end end + + class ExtraFieldTest < self + def test_load + statistics = parse(<<-LOG) +2017-12-11 09:37:04.516938|0x7fffc430dff0|>load --table Numbers +2017-12-11 09:37:04.517993|0x7fffc430dff0|:000000001056310 load(3): [1][2][3] +2017-12-11 09:37:04.517999|0x7fffc430dff0|<000000001061996 rc=-22 + LOG + operations = statistics.first.operations.collect do |operation| + [operation[:name], operation[:n_records], operation[:extra]] + end + expected = [ + ["load", 3, "[1][2][3]"], + ] + assert_equal(expected, operations) + end + end end -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171211/6587edde/attachment-0001.htm