shogi-server source
Revisión | 8c17b8b4420d4228d0c099e33f6417410adb9256 (tree) |
---|---|
Tiempo | 2017-09-03 14:39:13 |
Autor | Daigo Moriwaki <daigo@debi...> |
Commiter | Daigo Moriwaki |
[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)
@@ -1,3 +1,13 @@ | ||
1 | +2017-09-03 Daigo Moriwaki <daigo at debian dot org> | |
2 | + | |
3 | + * [shogi-server] Write game results in categorical files | |
4 | + The shogi-server now writes down game results in the following | |
5 | + files, depending on a game class: | |
6 | + - 00LIST: all games | |
7 | + - 00LIST.floodgate: floodgate games | |
8 | + - 00LIST.others: non-floodgate games | |
9 | + (Closes #37492) | |
10 | + | |
1 | 11 | 2017-09-02 Daigo Moriwaki <daigo at debian dot org> |
2 | 12 | |
3 | 13 | * [shogi-server] Write more game results in record files |
@@ -37,7 +37,9 @@ end | ||
37 | 37 | # |
38 | 38 | class LoggingObserver |
39 | 39 | def initialize |
40 | - @logfile = File.join($league.dir, "00LIST") | |
40 | + @logfile = File.join($league.dir, "00LIST") | |
41 | + @logfile_floodgate = File.join($league.dir, "00LIST.floodgate") | |
42 | + @logfile_others = File.join($league.dir, "00LIST.others") | |
41 | 43 | end |
42 | 44 | |
43 | 45 | def update(game_result) |
@@ -55,9 +57,18 @@ class LoggingObserver | ||
55 | 57 | game_result.game.logfile, |
56 | 58 | game_result.game.board.move_count] |
57 | 59 | begin |
60 | + files = [@logfile] | |
61 | + if League::Floodgate.game_name?(game_result.game.game_name) | |
62 | + files << @logfile_floodgate | |
63 | + else | |
64 | + files << @logfile_others | |
65 | + end | |
58 | 66 | # Note that this is proccessed in the gian lock. |
59 | - File.open(@logfile, "a") do |f| | |
60 | - f << msg.join("\t") << "\n" | |
67 | + str = msg.join("\t") | |
68 | + files.each do |file| | |
69 | + File.open(file, "a") do |f| | |
70 | + f.puts str | |
71 | + end | |
61 | 72 | end |
62 | 73 | rescue => e |
63 | 74 | # ignore |