aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct_logs.erl
diff options
context:
space:
mode:
authorLukas <[email protected]>2011-09-26 12:01:57 +0200
committerLukas <[email protected]>2011-09-26 12:01:57 +0200
commit516cbd4312c6fc8ca082d763b9a295acbc7e395c (patch)
treed9e8ff409547a52497ff53e75b2216f80d759d62 /lib/common_test/src/ct_logs.erl
parent97f3a064f27843a9f825210c1c7a27075b7b3ad7 (diff)
parent7d0d76f3a8170ddb5a3b07fd46fce835bb631cef (diff)
downloadotp-516cbd4312c6fc8ca082d763b9a295acbc7e395c.tar.gz
otp-516cbd4312c6fc8ca082d763b9a295acbc7e395c.tar.bz2
otp-516cbd4312c6fc8ca082d763b9a295acbc7e395c.zip
Merge branch 'lukas/common_test/system_logs_to_ct_log/OTP-9543' into dev
* lukas/common_test/system_logs_to_ct_log/OTP-9543: Add documentation for cth_log_redirect and built-in hooks Correct wrong match from lists:keyfind Update cth_log_redirect to wait for all error_logger events before ending test Force logging to framework log for parallel tests Add ct_log:ct_log funcion Add a hook for redirecting SASL and error_logger messages Add -enable_builtin_hooks <bool> config option Export write_events and add option to return a string
Diffstat (limited to 'lib/common_test/src/ct_logs.erl')
-rw-r--r--lib/common_test/src/ct_logs.erl26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl
index b839521e24..6a90441d53 100644
--- a/lib/common_test/src/ct_logs.erl
+++ b/lib/common_test/src/ct_logs.erl
@@ -36,7 +36,7 @@
-export([make_all_suites_index/1,make_all_runs_index/1]).
%% Logging stuff directly from testcase
--export([tc_log/3,tc_print/3,tc_pal/3,
+-export([tc_log/3,tc_print/3,tc_pal/3,ct_log/3,
basic_html/0]).
%% Simulate logger process for use without ct environment running
@@ -360,6 +360,23 @@ tc_pal(Category,Format,Args) ->
ok.
+%%%-----------------------------------------------------------------
+%%% @spec tc_pal(Category,Format,Args) -> ok
+%%% Category = atom()
+%%% Format = string()
+%%% Args = list()
+%%%
+%%% @doc Print and log to the ct framework log
+%%%
+%%% <p>This function is called by internal ct functions to
+%%% force logging to the ct framework log</p>
+ct_log(Category,Format,Args) ->
+ cast({ct_log,[{div_header(Category),[]},
+ {Format,Args},
+ {div_footer(),[]}]}),
+ ok.
+
+
%%%=================================================================
%%% Internal functions
int_header() ->
@@ -516,7 +533,12 @@ logger_loop(State) ->
{clear_stylesheet,_} when State#logger_state.stylesheet == undefined ->
logger_loop(State);
{clear_stylesheet,_} ->
- logger_loop(State#logger_state{stylesheet=undefined});
+ logger_loop(State#logger_state{stylesheet=undefined});
+ {ct_log, List} ->
+ Fd = State#logger_state.ct_log_fd,
+ [begin io:format(Fd,Str,Args),io:nl(Fd) end ||
+ {Str,Args} <- List],
+ logger_loop(State);
stop ->
io:format(State#logger_state.ct_log_fd,
int_header()++int_footer(),