OSDN Git Service

Merge remote-tracking branch 'origin/master' into wdoor-stable 20170902
authorDaigo Moriwaki <daigo@debian.org>
Sun, 3 Sep 2017 05:40:39 +0000 (14:40 +0900)
committerDaigo Moriwaki <daigo@debian.org>
Sun, 3 Sep 2017 05:40:39 +0000 (14:40 +0900)
changelog
shogi_server/game_result.rb

index afd2d3b..75667d2 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,13 @@
+2017-09-03  Daigo Moriwaki <daigo at debian dot org>
+
+       * [shogi-server] Write game results in categorical files
+         The shogi-server now writes down game results in the following
+         files, depending on a game class:
+         - 00LIST: all games
+         - 00LIST.floodgate: floodgate games
+         - 00LIST.others: non-floodgate games
+         (Closes  #37492)
+
 2017-09-02  Daigo Moriwaki <daigo at debian dot org>
 
        * [shogi-server] Write more game results in record files
index 15542de..5e0bd36 100644 (file)
@@ -37,7 +37,9 @@ end
 #
 class LoggingObserver
   def initialize
-    @logfile = File.join($league.dir, "00LIST")
+    @logfile           = File.join($league.dir, "00LIST")
+    @logfile_floodgate = File.join($league.dir, "00LIST.floodgate")
+    @logfile_others    = File.join($league.dir, "00LIST.others")
   end
 
   def update(game_result)
@@ -55,9 +57,18 @@ class LoggingObserver
            game_result.game.logfile,
           game_result.game.board.move_count]
     begin
+      files = [@logfile]
+      if League::Floodgate.game_name?(game_result.game.game_name)
+       files << @logfile_floodgate
+      else
+       files << @logfile_others
+      end
       # Note that this is proccessed in the gian lock.
-      File.open(@logfile, "a") do |f|
-        f << msg.join("\t") << "\n"
+      str = msg.join("\t")
+      files.each do |file|
+        File.open(file, "a") do |f|
+         f.puts str
+        end
       end
     rescue => e
       # ignore