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