Kouhei Sutou
null+****@clear*****
Fri May 24 18:21:04 JST 2013
Kouhei Sutou 2013-05-24 18:21:04 +0900 (Fri, 24 May 2013) New Revision: dfec7d88a9e4d57fbf85c27079de3b52374b12ca https://github.com/groonga/groonga-query-log/commit/dfec7d88a9e4d57fbf85c27079de3b52374b12ca Message: Ignore invalid line in query.log Modified files: lib/groonga/query-log/parser.rb test/test-parser.rb Modified: lib/groonga/query-log/parser.rb (+2 -1) =================================================================== --- lib/groonga/query-log/parser.rb 2013-05-24 18:05:48 +0900 (35db5fb) +++ lib/groonga/query-log/parser.rb 2013-05-24 18:21:04 +0900 (dcd3b32) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2011-2012 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2011-2013 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 @@ -38,6 +38,7 @@ module Groonga def parse(input, &block) current_statistics = {} input.each_line do |line| + next unless line.valid_encoding? case line when /\A(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)\.(\d+)\|(.+?)\|([>:<])/ year, month, day, hour, minutes, seconds, micro_seconds = Modified: test/test-parser.rb (+12 -1) =================================================================== --- test/test-parser.rb 2013-05-24 18:05:48 +0900 (54664d8) +++ test/test-parser.rb 2013-05-24 18:21:04 +0900 (7d5ec0c) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2011-2012 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2011-2013 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 @@ -26,6 +26,17 @@ EOL assert_instance_of(Groonga::Command::Load, parsed_command) end + def test_ignore_invalid_line + garbage = "\x80" + @log = <<-EOL +2012-12-13 11:15:20.628105|0x7fff148c8a50|>#{garbage} +2012-12-13 11:15:21.628105|0x7fff148c8a50|>load --table Video +2012-12-13 11:15:21.645119|0x7fff148c8a50|<000000017041150 rc=0 +EOL + parsed_command = statistics.first.command + assert_instance_of(Groonga::Command::Load, parsed_command) + end + private def statistics statistics = [] -------------- next part -------------- HTML����������������������������... 下载