aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct_conn_log_h.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2014-01-10 16:03:54 +0100
committerPeter Andersson <[email protected]>2014-01-27 19:38:10 +0100
commit584f9ec69fea19e1fed4a37699cb83e0d3c9bf94 (patch)
treef96bef67262602c13d7102c8d887b86417376a7c /lib/common_test/src/ct_conn_log_h.erl
parentbece9227ecffb5f164a383a826f63835bd32175a (diff)
downloadotp-584f9ec69fea19e1fed4a37699cb83e0d3c9bf94.tar.gz
otp-584f9ec69fea19e1fed4a37699cb83e0d3c9bf94.tar.bz2
otp-584f9ec69fea19e1fed4a37699cb83e0d3c9bf94.zip
Implement new telnet logging system
Diffstat (limited to 'lib/common_test/src/ct_conn_log_h.erl')
-rw-r--r--lib/common_test/src/ct_conn_log_h.erl22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/common_test/src/ct_conn_log_h.erl b/lib/common_test/src/ct_conn_log_h.erl
index ac08a3e0ad..550f62f4c1 100644
--- a/lib/common_test/src/ct_conn_log_h.erl
+++ b/lib/common_test/src/ct_conn_log_h.erl
@@ -96,6 +96,10 @@ terminate(_,#state{logs=Logs}) ->
%%%-----------------------------------------------------------------
%%% Writing reports
+write_report(_Time,#conn_log{header=false,module=ConnMod}=Info,Data,State) ->
+ {LogType,Fd} = get_log(Info,State),
+ io:format(Fd,"~n~ts",[format_data(ConnMod,LogType,Data)]);
+
write_report(Time,#conn_log{module=ConnMod}=Info,Data,State) ->
{LogType,Fd} = get_log(Info,State),
io:format(Fd,"~n~ts~ts~ts",[format_head(ConnMod,LogType,Time),
@@ -147,7 +151,12 @@ format_head(ConnMod,_,Time,Text) ->
io_lib:format("~n~ts",[Head]).
format_title(raw,#conn_log{client=Client}=Info) ->
- io_lib:format("Client ~w ~s ~ts",[Client,actionstr(Info),serverstr(Info)]);
+ case actionstr(Info) of
+ {no_server,Action} ->
+ io_lib:format("Client ~w ~s",[Client,Action]);
+ Action ->
+ io_lib:format("Client ~w ~s ~ts",[Client,Action,serverstr(Info)])
+ end;
format_title(_,Info) ->
Title = pad_char_end(?WIDTH,pretty_title(Info),$=),
io_lib:format("~n~ts", [Title]).
@@ -195,13 +204,20 @@ pretty_title(#conn_log{client=Client}=Info) ->
[Client,actionstr(Info),serverstr(Info)]).
actionstr(#conn_log{action=send}) -> "----->";
+actionstr(#conn_log{action=cmd}) -> "----->";
actionstr(#conn_log{action=recv}) -> "<-----";
-actionstr(#conn_log{action=open}) -> "opened session to";
-actionstr(#conn_log{action=close}) -> "closed session to";
+actionstr(#conn_log{action=open}) -> "open session to";
+actionstr(#conn_log{action=close}) -> "close session to";
+actionstr(#conn_log{action=info}) -> {no_server,"info"};
+actionstr(#conn_log{action=error}) -> {no_server,"error"};
actionstr(_) -> "<---->".
+serverstr(#conn_log{name=undefined,address={undefined,_}}) ->
+ io_lib:format("server",[]);
serverstr(#conn_log{name=undefined,address=Address}) ->
io_lib:format("~p",[Address]);
+serverstr(#conn_log{name=Alias,address={undefined,_}}) ->
+ io_lib:format("~w()",[Alias]);
serverstr(#conn_log{name=Alias,address=Address}) ->
io_lib:format("~w(~p)",[Alias,Address]).