From ad4ccadc153a2c4d65c5b6bc166dd549a7c3297c Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Tue, 26 Apr 2011 18:41:05 +0200 Subject: [PATCH] added possibility to log in file --- games/Pong/Classes/GGSNetwork.m | 2 +- .../UserInterfaceState.xcuserstate | 16 ++++++------- src/ggs_stats.erl | 24 +++++++++++++------ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/games/Pong/Classes/GGSNetwork.m b/games/Pong/Classes/GGSNetwork.m index 32f53f0..45e7719 100644 --- a/games/Pong/Classes/GGSNetwork.m +++ b/games/Pong/Classes/GGSNetwork.m @@ -11,7 +11,7 @@ @implementation GGSNetwork -#define GGS_HOST @"localhost" +#define GGS_HOST @"ggs.jeena.net" #define GGS_PORT 9000 #define NO_TIMEOUT -1 diff --git a/games/Pong/Pong.xcodeproj/project.xcworkspace/xcuserdata/jeena.xcuserdatad/UserInterfaceState.xcuserstate b/games/Pong/Pong.xcodeproj/project.xcworkspace/xcuserdata/jeena.xcuserdatad/UserInterfaceState.xcuserstate index ab2b7a0..3cfdb80 100644 --- a/games/Pong/Pong.xcodeproj/project.xcworkspace/xcuserdata/jeena.xcuserdatad/UserInterfaceState.xcuserstate +++ b/games/Pong/Pong.xcodeproj/project.xcworkspace/xcuserdata/jeena.xcuserdatad/UserInterfaceState.xcuserstate @@ -559,9 +559,9 @@ PrimaryDocumentVisibleCharacterRange HideAllIssues PrimaryDocumentSelectedCharacterRange - 325523158.10638702 - {0, 678} - {207, 0} + 325528851.05899101 + {0, 682} + {198, 13} $class @@ -1059,7 +1059,7 @@ 102 NS.time - 325523153.65744901 + 325523995.81053603 $classes @@ -1070,7 +1070,7 @@ $classname NSDate - Today at 17:05 + Today at 17:19 $classes @@ -1839,9 +1839,9 @@ - 325523158.10676903 - {0, 678} - {207, 0} + 325528851.05936098 + {0, 682} + {198, 13} $classes diff --git a/src/ggs_stats.erl b/src/ggs_stats.erl index 5959e75..e106ddb 100644 --- a/src/ggs_stats.erl +++ b/src/ggs_stats.erl @@ -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]).