aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sasl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2018-04-24 15:18:31 +0200
committerSiri Hansen <[email protected]>2018-04-26 14:37:31 +0200
commit291cf6d8530f4e0ad2f22f199b5ae6975135bbb3 (patch)
treedb38f4923022a0a58a6f08af7efe7ec97ba748d6 /lib/sasl
parentd22fa5406d1b974f1a0c25f580e83093bf84b02b (diff)
downloadotp-291cf6d8530f4e0ad2f22f199b5ae6975135bbb3.tar.gz
otp-291cf6d8530f4e0ad2f22f199b5ae6975135bbb3.tar.bz2
otp-291cf6d8530f4e0ad2f22f199b5ae6975135bbb3.zip
Test cuddle for logger
Diffstat (limited to 'lib/sasl')
-rw-r--r--lib/sasl/test/sasl_SUITE.erl14
-rw-r--r--lib/sasl/test/sasl_report_SUITE.erl18
2 files changed, 25 insertions, 7 deletions
diff --git a/lib/sasl/test/sasl_SUITE.erl b/lib/sasl/test/sasl_SUITE.erl
index f12bde9b3d..7b63684c53 100644
--- a/lib/sasl/test/sasl_SUITE.erl
+++ b/lib/sasl/test/sasl_SUITE.erl
@@ -21,6 +21,7 @@
-include_lib("common_test/include/ct.hrl").
%% Test server specific exports
+-export([init_per_suite/1,end_per_suite/1]).
-export([all/0,groups/0,init_per_group/2,end_per_group/2]).
-export([init_per_testcase/2, end_per_testcase/2]).
@@ -37,6 +38,19 @@ all() ->
groups() ->
[].
+init_per_suite(Config) ->
+ S = application:get_env(kernel,logger_sasl_compatible),
+ application:set_env(kernel,logger_sasl_compatible,true),
+ [{sasl_compatible,S}|Config].
+
+end_per_suite(Config) ->
+ case ?config(sasl_compatible,Config) of
+ {ok,X} ->
+ application:set_env(kernel,logger_sasl_compatible,X);
+ undefined ->
+ application:unset_env(kernel,logger_sasl_compatible)
+ end.
+
init_per_group(_GroupName, Config) ->
Config.
diff --git a/lib/sasl/test/sasl_report_SUITE.erl b/lib/sasl/test/sasl_report_SUITE.erl
index 92df5e6e40..96975aaf69 100644
--- a/lib/sasl/test/sasl_report_SUITE.erl
+++ b/lib/sasl/test/sasl_report_SUITE.erl
@@ -53,13 +53,17 @@ gen_server_crash_unicode(Config) ->
gen_server_crash(Config, unicode).
gen_server_crash(Config, Encoding) ->
+ StopFilter = {fun(_,_) -> stop end, ok},
+ logger:add_handler_filter(logger_std_h,stop_all,StopFilter),
+ logger:add_handler_filter(cth_log_redirect,stop_all,StopFilter),
try
do_gen_server_crash(Config, Encoding)
after
- error_logger:tty(true),
+ ok = application:unset_env(kernel, logger_sasl_compatible),
ok = application:unset_env(sasl, sasl_error_logger),
ok = application:unset_env(kernel, error_logger_format_depth),
- error_logger:add_report_handler(cth_log_redirect)
+ logger:remove_handler_filter(logger_std_h,stop_all),
+ logger:remove_handler_filter(cth_log_redirect,stop_all)
end,
ok.
@@ -70,26 +74,26 @@ do_gen_server_crash(Config, Encoding) ->
SaslLog = filename:join(LogDir, "sasl.log"),
ok = filelib:ensure_dir(SaslLog),
- error_logger:delete_report_handler(cth_log_redirect),
- error_logger:tty(false),
application:stop(sasl),
Modes = [write, {encoding, Encoding}],
+ ok = application:set_env(kernel, logger_sasl_compatible, true),
ok = application:set_env(sasl, sasl_error_logger, {file,SaslLog,Modes},
[{persistent,true}]),
application:set_env(kernel, error_logger_format_depth, 30),
error_logger:logfile({open,KernelLog}),
application:start(sasl),
- io:format("~p\n", [gen_event:which_handlers(error_logger)]),
+ logger:i(print),
crash_me(),
error_logger:logfile(close),
+ application:stop(sasl),
check_file(KernelLog, utf8, 70000, 150000),
check_file(SaslLog, Encoding, 70000, 150000),
- %% ok = file:delete(KernelLog),
- %% ok = file:delete(SaslLog),
+ ok = file:delete(KernelLog),
+ ok = file:delete(SaslLog),
ok.
check_file(File, Encoding, Min, Max) ->