Kouhei Sutou
null+****@clear*****
Mon Jan 15 14:35:28 JST 2018
Kouhei Sutou 2018-01-15 14:35:28 +0900 (Mon, 15 Jan 2018) New Revision: ac7529ee09701a6421d20090485c7b3b952be866 https://github.com/groonga/groonga-log/commit/ac7529ee09701a6421d20090485c7b3b952be866 Message: Statistic -> Entry Because data in Groonga log aren't statistic information. Modified files: lib/groonga-log.rb lib/groonga-log/parser.rb test/test-parser.rb Renamed files: lib/groonga-log/entry.rb (from lib/groonga-log/statistic.rb) Modified: lib/groonga-log.rb (+1 -2) =================================================================== --- lib/groonga-log.rb 2018-01-15 14:31:48 +0900 (95d3d2a) +++ lib/groonga-log.rb 2018-01-15 14:35:28 +0900 (cdbc5b8) @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2017-2018 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 @@ -15,5 +15,4 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA require "groonga-log/parser" -require "groonga-log/statistic" require "groonga-log/version" Renamed: lib/groonga-log/entry.rb (+5 -5) 77% =================================================================== --- lib/groonga-log/statistic.rb 2018-01-15 14:31:48 +0900 (0e72059) +++ lib/groonga-log/entry.rb 2018-01-15 14:35:28 +0900 (cbb870b) @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2017-2018 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 @@ -15,9 +15,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA module GroongaLog - class Statistic < Struct.new(:timestamp, - :log_level, - :pid, - :message) + class Entry < Struct.new(:timestamp, + :log_level, + :pid, + :message) end end Modified: lib/groonga-log/parser.rb (+8 -8) =================================================================== --- lib/groonga-log/parser.rb 2018-01-15 14:31:48 +0900 (314d3c8) +++ lib/groonga-log/parser.rb 2018-01-15 14:35:28 +0900 (902e525) @@ -15,7 +15,7 @@ # 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-log/statistic" +require "groonga-log/entry" module GroongaLog class Parser @@ -62,7 +62,7 @@ module GroongaLog m = PATTERN.match(line) - statistic = Statistic.new + entry = Entry.new year = m["year"].to_i month = m["month"].to_i @@ -71,12 +71,12 @@ module GroongaLog minute = m["minute"].to_i second = m["second"].to_i micro_second = m["micro_second"].to_i - statistic.timestamp = Time.local(year, month, day, - hour, minute, second, micro_second) - statistic.log_level = log_level_to_symbol(m["log_level"]) - statistic.pid = m["pid"].to_i if m["pid"] - statistic.message = m["message"] - yield statistic + entry.timestamp = Time.local(year, month, day, + hour, minute, second, micro_second) + entry.log_level = log_level_to_symbol(m["log_level"]) + entry.pid = m["pid"].to_i if m["pid"] + entry.message = m["message"] + yield entry end end Modified: test/test-parser.rb (+13 -12) =================================================================== --- test/test-parser.rb 2018-01-15 14:31:48 +0900 (5e3848e) +++ test/test-parser.rb 2018-01-15 14:35:28 +0900 (32e15be) @@ -1,5 +1,6 @@ -# Copyright (C) 2017 Yasuhiro Horimoto <horimoto �� clear-code.com> -# Copyright (C) 2017 Kentaro Hayashi <hayashi �� clear-code.com> +# Copyright (C) 2017 Yasuhiro Horimoto <horimoto �� clear-code.com> +# Copyright (C) 2017 Kentaro Hayashi <hayashi �� clear-code.com> +# Copyright (C) 2018 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 @@ -20,31 +21,31 @@ require "helper" class ParserTest < Test::Unit::TestCase sub_test_case("extract fields") do def test_with_pid - raw_statistic = { + raw_entry = { :timestamp => Time.local(2017, 7, 19, 14, 9, 5, 663978), :log_level => :notice, :pid => 29, :message => "spec:2:update:Object:32(type):8", } - statistics = parse(<<-LOG) + entries = parse(<<-LOG) 2017-07-19 14:09:05.663978|n|29: spec:2:update:Object:32(type):8 LOG - assert_equal([raw_statistic], - statistics.collect(&:to_h)) + assert_equal([raw_entry], + entries.collect(&:to_h)) end def test_without_pid - raw_statistic = { + raw_entry = { :timestamp => Time.local(2017, 7, 19, 14, 9, 5, 663978), :log_level => :notice, :pid => nil, :message => "spec:2:update:Object:32(type):8", } - statistics = parse(<<-LOG) + entries = parse(<<-LOG) 2017-07-19 14:09:05.663978|n| spec:2:update:Object:32(type):8 LOG - assert_equal([raw_statistic], - statistics.collect(&:to_h)) + assert_equal([raw_entry], + entries.collect(&:to_h)) end end @@ -60,7 +61,7 @@ class ParserTest < Test::Unit::TestCase :debug, :dump ] - statistics = parse(<<-LOG) + entries = parse(<<-LOG) 2017-07-19 14:41:05.663978|E|29: emergency 2017-07-19 14:41:06.663978|A| alert 2017-07-19 14:41:06.663978|C|29: critical @@ -72,7 +73,7 @@ class ParserTest < Test::Unit::TestCase 2017-07-19 14:41:06.663978|-|29: dump LOG assert_equal(expected, - statistics.collect(&:log_level)) + entries.collect(&:log_level)) end private -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180115/f7a6d4e4/attachment-0001.htm