added possibility to log in file
This commit is contained in:
parent
e5f2652ae6
commit
ad4ccadc15
3 changed files with 26 additions and 16 deletions
|
@ -11,7 +11,7 @@
|
|||
|
||||
@implementation GGSNetwork
|
||||
|
||||
#define GGS_HOST @"localhost"
|
||||
#define GGS_HOST @"ggs.jeena.net"
|
||||
#define GGS_PORT 9000
|
||||
#define NO_TIMEOUT -1
|
||||
|
||||
|
|
|
@ -559,9 +559,9 @@
|
|||
<string>PrimaryDocumentVisibleCharacterRange</string>
|
||||
<string>HideAllIssues</string>
|
||||
<string>PrimaryDocumentSelectedCharacterRange</string>
|
||||
<real>325523158.10638702</real>
|
||||
<string>{0, 678}</string>
|
||||
<string>{207, 0}</string>
|
||||
<real>325528851.05899101</real>
|
||||
<string>{0, 682}</string>
|
||||
<string>{198, 13}</string>
|
||||
<dict>
|
||||
<key>$class</key>
|
||||
<dict>
|
||||
|
@ -1059,7 +1059,7 @@
|
|||
<integer>102</integer>
|
||||
</dict>
|
||||
<key>NS.time</key>
|
||||
<real>325523153.65744901</real>
|
||||
<real>325523995.81053603</real>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>$classes</key>
|
||||
|
@ -1070,7 +1070,7 @@
|
|||
<key>$classname</key>
|
||||
<string>NSDate</string>
|
||||
</dict>
|
||||
<string>Today at 17:05</string>
|
||||
<string>Today at 17:19</string>
|
||||
<dict>
|
||||
<key>$classes</key>
|
||||
<array>
|
||||
|
@ -1839,9 +1839,9 @@
|
|||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
<real>325523158.10676903</real>
|
||||
<string>{0, 678}</string>
|
||||
<string>{207, 0}</string>
|
||||
<real>325528851.05936098</real>
|
||||
<string>{0, 682}</string>
|
||||
<string>{198, 13}</string>
|
||||
<dict>
|
||||
<key>$classes</key>
|
||||
<array>
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
|
||||
-record(ate, {
|
||||
server_messages = 0,
|
||||
client_messages = 0
|
||||
client_messages = 0,
|
||||
stats = []
|
||||
}).
|
||||
-define(SERVER, ?MODULE).
|
||||
|
||||
|
@ -29,7 +30,8 @@ start_link() ->
|
|||
init(_Args) ->
|
||||
St = #ate{
|
||||
server_messages = 0,
|
||||
client_messages = 0
|
||||
client_messages = 0,
|
||||
stats = []
|
||||
},
|
||||
{ok, St}.
|
||||
|
||||
|
@ -37,23 +39,28 @@ handle_cast({add_one, Type}, St) ->
|
|||
case Type of
|
||||
server -> NewSt = #ate {
|
||||
server_messages = St#ate.server_messages + 1,
|
||||
client_messages = St#ate.client_messages
|
||||
client_messages = St#ate.client_messages,
|
||||
stats = St#ate.stats
|
||||
};
|
||||
client -> NewSt = #ate {
|
||||
server_messages = St#ate.server_messages,
|
||||
client_messages = St#ate.client_messages + 1
|
||||
client_messages = St#ate.client_messages + 1,
|
||||
stats = St#ate.stats
|
||||
}
|
||||
end,
|
||||
{noreply, NewSt};
|
||||
|
||||
handle_cast(print, St) ->
|
||||
CS = length(ggs_coordinator:get_all_players()),
|
||||
io:fwrite("CS:~w | CM:~w | SM:~w~n", [CS, St#ate.server_messages, St#ate.client_messages]),
|
||||
S = lists:concat([CS,";",St#ate.server_messages,";",St#ate.client_messages]),
|
||||
log("/tmp/ggs-log.csv", S),
|
||||
io:fwrite("CS:~w | CM:~w | SM:~w |~n", [CS, St#ate.server_messages, St#ate.client_messages]),
|
||||
{noreply, St};
|
||||
|
||||
handle_cast(tick, _St) ->
|
||||
handle_cast(tick, St) ->
|
||||
NewSt = #ate { server_messages = 0,
|
||||
client_messages = 0 },
|
||||
client_messages = 0,
|
||||
stats = St#ate.stats },
|
||||
{noreply, NewSt}.
|
||||
|
||||
|
||||
|
@ -62,3 +69,6 @@ handle_call(_Request, _From, St) -> {stop, unimplemented, St}.
|
|||
handle_info(_Info, St) -> {stop, unimplemented, St}.
|
||||
terminate(_Reason, _St) -> ok.
|
||||
code_change(_OldVsn, St, _Extra) -> {ok, St}.
|
||||
|
||||
log(FileName, Data) ->
|
||||
file:write_file(FileName, Data ++ "\n", [append]).
|
||||
|
|
Reference in a new issue