Kouhei Sutou
null+****@clear*****
Mon Jul 30 17:12:13 JST 2018
Kouhei Sutou 2018-07-30 17:12:13 +0900 (Mon, 30 Jul 2018) New Revision: 34b603596f7d97e4859fabad57f82494c91bafa2 https://github.com/groonga/groonga-log/commit/34b603596f7d97e4859fabad57f82494c91bafa2 Message: Support both PID and thread ID case Modified files: lib/groonga-log/parser.rb test/test-parser.rb Modified: lib/groonga-log/parser.rb (+4 -3) =================================================================== --- lib/groonga-log/parser.rb 2018-07-30 16:47:43 +0900 (fb69f25) +++ lib/groonga-log/parser.rb 2018-07-30 17:12:13 +0900 (6e24f54) @@ -23,9 +23,10 @@ module GroongaLog class Parser PATTERN = /\A(?<year>\d{4})-(?<month>\d\d)-(?<day>\d\d) - \ (?<hour>\d\d):(?<minute>\d\d):(?<second>\d\d)\.(?<micro_second>\d+) - \|(?<log_level>.) - \|(?:(?:(?<pid>\d+):|(?<thread_id>[\da-fA-F]+)\|))? + \ (?<hour>\d\d):(?<minute>\d\d):(?<second>\d\d)\.(?<micro_second>\d+)\| + (?<log_level>.)\| + (?:(?<pid>\d+)[|:])? + (?:(?<thread_id>[\da-fA-F]+)[|:])? \ ?(?<message>[^\r\n]*)/x PATH_TIMESTAMP_PATTERN = /(\d{4})-(\d{2})-(\d{2})- (\d{2})-(\d{2})-(\d{2})-(\d{6}) Modified: test/test-parser.rb (+15 -0) =================================================================== --- test/test-parser.rb 2018-07-30 16:47:43 +0900 (c533a56) +++ test/test-parser.rb 2018-07-30 17:12:13 +0900 (e33e96e) @@ -62,6 +62,21 @@ class InputTest < Test::Unit::TestCase assert_equal([raw_entry], entries.collect(&:to_h)) end + + def test_with_pid_and_thread_id + raw_entry = { + :timestamp => Time.local(2017, 7, 19, 14, 9, 5, 663978), + :log_level => :notice, + :pid => 29, + :thread_id => "528b9700", + :message => "spec:2:update:Object:32(type):8", + } + entries = parse(<<-LOG) +2017-07-19 14:09:05.663978|n|29|528b9700: spec:2:update:Object:32(type):8 + LOG + assert_equal([raw_entry], + entries.collect(&:to_h)) + end end def test_log_level -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180730/e884e07f/attachment.htm