aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2015-09-28 16:45:05 +0200
committerSiri Hansen <[email protected]>2015-09-28 16:45:05 +0200
commit4cf832f1ad163f5b25dd8a6f2d314c169c23c82f (patch)
tree6987c5209de5707c36d1ab8e4a65af01f9d1dd04
parent67b38c36eaa9b6d3edb80df75637f0e8cd1823f3 (diff)
downloadotp-4cf832f1ad163f5b25dd8a6f2d314c169c23c82f.tar.gz
otp-4cf832f1ad163f5b25dd8a6f2d314c169c23c82f.tar.bz2
otp-4cf832f1ad163f5b25dd8a6f2d314c169c23c82f.zip
Don't log headings without content
The netconf server collects data until an XML tag is completed before pretty printing received data. Each time data is logged, a heading like the following is printed: = CT_NETCONFC ==== 28-Sep-2015::16:43:46,842 =================================== = Client <0.194.0> <----- {"127.0.0.1",2060} =================================== This commit removes printing of this header if there is no data to be printed below - i.e. if the XML tag is not yet complete and we are waiting for more data.
-rw-r--r--lib/common_test/src/ct_conn_log_h.erl11
-rw-r--r--lib/common_test/src/ct_netconfc.erl25
2 files changed, 27 insertions, 9 deletions
diff --git a/lib/common_test/src/ct_conn_log_h.erl b/lib/common_test/src/ct_conn_log_h.erl
index 2dd4fdac05..5eb67853d9 100644
--- a/lib/common_test/src/ct_conn_log_h.erl
+++ b/lib/common_test/src/ct_conn_log_h.erl
@@ -109,9 +109,14 @@ write_report(_Time,#conn_log{header=false,module=ConnMod}=Info,Data,GL,State) ->
write_report(Time,#conn_log{module=ConnMod}=Info,Data,GL,State) ->
{LogType,Fd} = get_log(Info,GL,State),
- io:format(Fd,"~n~ts~ts~ts",[format_head(ConnMod,LogType,Time),
- format_title(LogType,Info),
- format_data(ConnMod,LogType,Data)]).
+ case format_data(ConnMod,LogType,Data) of
+ [] ->
+ ok;
+ FormattedData ->
+ io:format(Fd,"~n~ts~ts~ts",[format_head(ConnMod,LogType,Time),
+ format_title(LogType,Info),
+ FormattedData])
+ end.
write_error(Time,#conn_log{module=ConnMod}=Info,Report,GL,State) ->
case get_log(Info,GL,State) of
diff --git a/lib/common_test/src/ct_netconfc.erl b/lib/common_test/src/ct_netconfc.erl
index 799d795ed0..ed805e4d14 100644
--- a/lib/common_test/src/ct_netconfc.erl
+++ b/lib/common_test/src/ct_netconfc.erl
@@ -1768,9 +1768,14 @@ format_data(How,Data) ->
do_format_data(raw,Data) ->
io_lib:format("~n~ts~n",[hide_password(Data)]);
do_format_data(pretty,Data) ->
- io_lib:format("~n~ts~n",[indent(Data)]);
+ maybe_io_lib_format(indent(Data));
do_format_data(html,Data) ->
- io_lib:format("~n~ts~n",[html_format(Data)]).
+ maybe_io_lib_format(html_format(Data)).
+
+maybe_io_lib_format(<<>>) ->
+ [];
+maybe_io_lib_format(String) ->
+ io_lib:format("~n~ts~n",[String]).
%%%-----------------------------------------------------------------
%%% Hide password elements from XML data
@@ -1809,13 +1814,21 @@ indent1("<?"++Rest1,Indent1) ->
Line++indent1(Rest2,Indent2);
indent1("</"++Rest1,Indent1) ->
%% Stop tag
- {Line,Rest2,Indent2} = indent_line1(Rest1,Indent1,[$/,$<]),
- "\n"++Line++indent1(Rest2,Indent2);
+ case indent_line1(Rest1,Indent1,[$/,$<]) of
+ {[],[],_} ->
+ [];
+ {Line,Rest2,Indent2} ->
+ "\n"++Line++indent1(Rest2,Indent2)
+ end;
indent1("<"++Rest1,Indent1) ->
%% Start- or empty tag
put(tag,get_tag(Rest1)),
- {Line,Rest2,Indent2} = indent_line(Rest1,Indent1,[$<]),
- "\n"++Line++indent1(Rest2,Indent2);
+ case indent_line(Rest1,Indent1,[$<]) of
+ {[],[],_} ->
+ [];
+ {Line,Rest2,Indent2} ->
+ "\n"++Line++indent1(Rest2,Indent2)
+ end;
indent1([H|T],Indent) ->
[H|indent1(T,Indent)];
indent1([],_Indent) ->