[Groonga-commit] groonga/groonga-log at fe265a1 [master] Remove duplicated data

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Sep 28 09:10:18 JST 2017


Kouhei Sutou	2017-09-28 09:10:18 +0900 (Thu, 28 Sep 2017)

  New Revision: fe265a1f66f8e25aefbcaa71355f187b0ee50cd5
  https://github.com/groonga/groonga-log/commit/fe265a1f66f8e25aefbcaa71355f187b0ee50cd5

  Message:
    Remove duplicated data

  Modified files:
    lib/groonga-log/parser.rb
    lib/groonga-log/statistic.rb
    test/test-parser.rb

  Modified: lib/groonga-log/parser.rb (+9 -7)
===================================================================
--- lib/groonga-log/parser.rb    2017-09-28 09:06:36 +0900 (0d29293)
+++ lib/groonga-log/parser.rb    2017-09-28 09:10:18 +0900 (293ffc2)
@@ -34,13 +34,15 @@ module GroongaLog
         m = PATTERN.match(line)
 
         statistic = Statistic.new
-        statistic.year = m['year'].to_i
-        statistic.month = m['month'].to_i
-        statistic.day = m['day'].to_i
-        statistic.hour = m['hour'].to_i
-        statistic.minute = m['minute'].to_i
-        statistic.second = m['second'].to_i
-        statistic.micro_second = m['micro_second'].to_i
+        year = m['year'].to_i
+        month = m['month'].to_i
+        day = m['day'].to_i
+        hour = m['hour'].to_i
+        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.context_id = m['context_id']
         statistic.message = m['message']

  Modified: lib/groonga-log/statistic.rb (+0 -16)
===================================================================
--- lib/groonga-log/statistic.rb    2017-09-28 09:06:36 +0900 (d8ac51a)
+++ lib/groonga-log/statistic.rb    2017-09-28 09:10:18 +0900 (363fecc)
@@ -16,24 +16,8 @@
 
 module GroongaLog
   class Statistic < Struct.new(:timestamp,
-                               :year,
-                               :month,
-                               :day,
-                               :hour,
-                               :minute,
-                               :second,
-                               :micro_second,
                                :log_level,
                                :context_id,
                                :message)
-    def timestamp
-      super || Time.local(year, month, day, hour, minute, second, micro_second)
-    end
-
-    def to_h
-      hash = super
-      hash[:timestamp] ||= timestamp
-      hash
-    end
   end
 end

  Modified: test/test-parser.rb (+0 -7)
===================================================================
--- test/test-parser.rb    2017-09-28 09:06:36 +0900 (766151b)
+++ test/test-parser.rb    2017-09-28 09:10:18 +0900 (8b1a8bf)
@@ -21,13 +21,6 @@ class ParserTest < Test::Unit::TestCase
   def test_extract_field
     raw_statistic = {
       :timestamp => Time.local(2017, 7, 19, 14, 9, 5, 663978),
-      :year => 2017,
-      :month => 7,
-      :day => 19,
-      :hour => 14,
-      :minute => 9,
-      :second => 5,
-      :micro_second => 663978,
       :log_level => :notice,
       :context_id => "18c61700",
       :message => "spec:2:update:Object:32(type):8",
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170928/db618ee8/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index