From 5e282d9ba621008355fbd9a9ff27310577404b98 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Sun, 11 Mar 2012 23:54:03 +0100 Subject: Introduce error notification printout in the tc log Also fix problem with parallel test cases printing "into each other" (when using ct:print or ct:pal). OTP-9904 OTP-9900 --- lib/common_test/src/ct_logs.erl | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'lib/common_test/src/ct_logs.erl') diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl index 5f0626c0b0..b2f669fefe 100644 --- a/lib/common_test/src/ct_logs.erl +++ b/lib/common_test/src/ct_logs.erl @@ -38,7 +38,7 @@ -export([get_ts_html_wrapper/3]). %% Logging stuff directly from testcase --export([tc_log/3,tc_log_async/3,tc_print/3,tc_pal/3,ct_log/3, +-export([tc_log/3,tc_log/4,tc_log_async/3,tc_print/3,tc_pal/3,ct_log/3, basic_html/0]). %% Simulate logger process for use without ct environment running @@ -333,7 +333,10 @@ add_link(Heading,File,Type) -> %%% stuff directly from a testcase (i.e. not from within the CT %%% framework).

tc_log(Category,Format,Args) -> - cast({log,sync,self(),group_leader(),[{div_header(Category),[]}, + tc_log(Category,"User",Format,Args). + +tc_log(Category,Printer,Format,Args) -> + cast({log,sync,self(),group_leader(),[{div_header(Category,Printer),[]}, {Format,Args}, {div_footer(),[]}]}), ok. @@ -369,19 +372,18 @@ tc_log_async(Category,Format,Args) -> %%%

This function is called by ct when printing %%% stuff a testcase on the user console.

tc_print(Category,Format,Args) -> - print_heading(Category), - io:format(user,Format,Args), - io:format(user,"\n\n",[]), + Head = get_heading(Category), + io:format(user, lists:concat([Head,Format,"\n\n"]), Args), ok. -print_heading(default) -> - io:format(user, - "----------------------------------------------------\n~s\n", - [log_timestamp(now())]); -print_heading(Category) -> - io:format(user, - "----------------------------------------------------\n~s ~w\n", - [log_timestamp(now()),Category]). +get_heading(default) -> + io_lib:format("-----------------------------" + "-----------------------\n~s\n", + [log_timestamp(now())]); +get_heading(Category) -> + io_lib:format("-----------------------------" + "-----------------------\n~s ~w\n", + [log_timestamp(now()),Category]). %%%----------------------------------------------------------------- @@ -428,8 +430,10 @@ int_footer() -> "". div_header(Class) -> - "
*** User " ++ - log_timestamp(now()) ++ " ***". + div_header(Class,"User"). +div_header(Class,Printer) -> + "
*** " ++ Printer ++ + " " ++ log_timestamp(now()) ++ " ***". div_footer() -> "
". -- cgit v1.2.3