aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel/test')
-rw-r--r--lib/kernel/test/logger_SUITE.erl30
-rw-r--r--lib/kernel/test/logger_bench_SUITE.erl2
-rw-r--r--lib/kernel/test/logger_disk_log_h_SUITE.erl12
-rw-r--r--lib/kernel/test/logger_env_var_SUITE.erl170
-rw-r--r--lib/kernel/test/logger_std_h_SUITE.erl11
5 files changed, 118 insertions, 107 deletions
diff --git a/lib/kernel/test/logger_SUITE.erl b/lib/kernel/test/logger_SUITE.erl
index ca0e7e23b5..da3345524a 100644
--- a/lib/kernel/test/logger_SUITE.erl
+++ b/lib/kernel/test/logger_SUITE.erl
@@ -50,7 +50,7 @@ init_per_suite(Config) ->
end_per_suite(Config) ->
case ?config(default_handler,Config) of
- {HMod,HConfig} ->
+ #{module:=HMod} = HConfig ->
ok = logger:add_handler(?STANDARD_HANDLER,HMod,HConfig);
_ ->
ok
@@ -111,8 +111,8 @@ add_remove_handler(_Config) ->
ok = logger:add_handler(h1,?MODULE,#{}),
[add] = test_server:messages_get(),
Hs = logger:get_handler_config(),
- {value,_,Hs0} = lists:keytake(h1,1,Hs),
- {ok,{?MODULE,#{level:=all,filters:=[],filter_default:=log}}} = % defaults
+ Hs0 = lists:filter(fun(#{id:=h1}) -> false; (_) -> true end, Hs),
+ {ok,#{module:=?MODULE,level:=all,filters:=[],filter_default:=log}} = %defaults
logger:get_handler_config(h1),
ok = logger:set_handler_config(h1,filter_default,stop),
[changing_config] = test_server:messages_get(),
@@ -120,7 +120,7 @@ add_remove_handler(_Config) ->
ok = check_no_log(),
ok = logger:set_handler_config(h1,filter_default,log),
[changing_config] = test_server:messages_get(),
- {ok,{?MODULE,#{filter_default:=log}}} = logger:get_handler_config(h1),
+ {ok,#{filter_default:=log}} = logger:get_handler_config(h1),
?LOG_INFO("hello",[]),
ok = check_logged(info,"hello",[],?MY_LOC(1)),
ok = logger:remove_handler(h1),
@@ -211,12 +211,12 @@ add_remove_filter(cleanup,_Config) ->
change_config(_Config) ->
%% Overwrite handler config - check that defaults are added
ok = logger:add_handler(h1,?MODULE,#{level=>info,custom=>custom}),
- {ok,{?MODULE,#{level:=info,filter_default:=log,custom:=custom}}} =
+ {ok,#{module:=?MODULE,level:=info,filter_default:=log,custom:=custom}} =
logger:get_handler_config(h1),
register(callback_receiver,self()),
ok = logger:set_handler_config(h1,#{filter_default=>stop}),
[changing_config] = test_server:messages_get(),
- {ok,{?MODULE,#{level:=all,filter_default:=stop}=C2}} =
+ {ok,#{module:=?MODULE,level:=all,filter_default:=stop}=C2} =
logger:get_handler_config(h1),
false = maps:is_key(custom,C2),
{error,fail} = logger:set_handler_config(h1,#{conf_call=>fun() -> {error,fail} end}),
@@ -226,19 +226,19 @@ change_config(_Config) ->
ok =
logger:set_handler_config(
h1,#{conf_call=>fun() -> logger:set_module_level(?MODULE,debug) end}),
- {ok,{?MODULE,C2}} = logger:get_handler_config(h1),
+ {ok,C2} = logger:get_handler_config(h1),
%% Change handler config: Single key
{error,fail} = logger:set_handler_config(h1,conf_call,fun() -> {error,fail} end),
ok = logger:set_handler_config(h1,custom,custom),
[changing_config] = test_server:messages_get(),
- {ok,{?MODULE,#{custom:=custom}=C3}} = logger:get_handler_config(h1),
+ {ok,#{custom:=custom}=C3} = logger:get_handler_config(h1),
C2 = maps:remove(custom,C3),
%% Change handler config: Map
ok = logger:update_handler_config(h1,#{custom=>new_custom}),
[changing_config] = test_server:messages_get(),
- {ok,{_,C4}} = logger:get_handler_config(h1),
+ {ok,C4} = logger:get_handler_config(h1),
C4 = C3#{custom:=new_custom},
%% Change primary config: Single key
@@ -259,9 +259,9 @@ change_config(_Config) ->
3 = maps:size(PC1),
%% Check that internal 'handlers' field has not been changed
MS = [{{{?HANDLER_KEY,'$1'},'_','_','_'},[],['$1']}],
- HIds1 = ets:select(?LOGGER_TABLE,MS), % dirty, checking internal data
+ HIds1 = lists:sort(ets:select(?LOGGER_TABLE,MS)), % dirty, internal data
HIds2 = lists:sort(logger:get_handler_ids()),
- HIds1 = lists:sort(HIds2),
+ HIds1 = HIds2,
%% Cleanup
ok = logger:set_primary_config(PConfig0),
@@ -488,13 +488,13 @@ filter_failed(_Config) ->
{error,{invalid_filter,_}} =
logger:add_handler_filter(h1,hf,{fun(_) -> ok end,args}),
ok = logger:add_handler_filter(h1,hf,{fun(_,_) -> a=b end,args}),
- {ok,{?MODULE,#{filters:=[_]}}} = logger:get_handler_config(h1),
+ {ok,#{filters:=[_]}} = logger:get_handler_config(h1),
ok = logger:info(M3=?map_rep),
ok = check_logged(info,M3,#{}),
{error,{not_found,hf}} = logger:remove_handler_filter(h1,hf),
ok = logger:add_handler_filter(h1,hf,{fun(_,_) -> faulty_return end,args}),
- {ok,{?MODULE,#{filters:=[_]}}} = logger:get_handler_config(h1),
+ {ok,#{filters:=[_]}} = logger:get_handler_config(h1),
ok = logger:info(M4=?map_rep),
ok = check_logged(info,M4,#{}),
{error,{not_found,hf}} = logger:remove_handler_filter(h1,hf),
@@ -520,7 +520,7 @@ handler_failed(_Config) ->
logger:info(?map_rep),
check_no_log(),
H1 = logger:get_handler_config(),
- false = lists:keymember(h1,1,H1),
+ false = lists:search(fun(#{id:=h1}) -> true; (_) -> false end,H1),
{error,{not_found,h1}} = logger:remove_handler(h1),
ok = logger:add_handler(h2,?MODULE,#{filter_default=>log,log_call=>fun() -> a = b end}),
@@ -530,7 +530,7 @@ handler_failed(_Config) ->
logger:info(?map_rep),
[remove] = test_server:messages_get(),
H2 = logger:get_handler_config(),
- false = lists:keymember(h2,1,H2),
+ false = lists:search(fun(#{id:=h2}) -> true; (_) -> false end,H2),
{error,{not_found,h2}} = logger:remove_handler(h2),
CallAddHandler = fun() -> logger:add_handler(h2,?MODULE,#{}) end,
diff --git a/lib/kernel/test/logger_bench_SUITE.erl b/lib/kernel/test/logger_bench_SUITE.erl
index b60fc42741..c6aa541a94 100644
--- a/lib/kernel/test/logger_bench_SUITE.erl
+++ b/lib/kernel/test/logger_bench_SUITE.erl
@@ -366,7 +366,7 @@ calc_and_report(Config,Tag,MSecs,Times) ->
remove_all_handlers() ->
Hs = logger:get_handler_config(),
- [logger:remove_handler(Id) || {Id,_,_} <- Hs],
+ [logger:remove_handler(Id) || #{id:=Id} <- Hs],
Hs.
add_all_handlers(Hs) ->
diff --git a/lib/kernel/test/logger_disk_log_h_SUITE.erl b/lib/kernel/test/logger_disk_log_h_SUITE.erl
index 552cb05797..8fefbd1426 100644
--- a/lib/kernel/test/logger_disk_log_h_SUITE.erl
+++ b/lib/kernel/test/logger_disk_log_h_SUITE.erl
@@ -328,13 +328,11 @@ formatter_fail(Config) ->
logger:add_handler(Name, logger_disk_log_h, HConfig),
Pid = whereis(h_proc_name(Name)),
true = is_pid(Pid),
- HC1 = logger:get_handler_config(),
- H = [Id || {Id,_,_} <- HC1],
+ H = logger:get_handler_ids(),
true = lists:member(Name,H),
%% Formatter is added automatically
- {ok,{_,#{formatter:={logger_formatter,_}}}} =
- logger:get_handler_config(Name),
+ {ok,#{formatter:={logger_formatter,_}}} = logger:get_handler_config(Name),
logger:info(M1=?msg,?domain),
Got1 = try_match_file(?log_no(LogFile,1),"[0-9\\+\\-T:\\.]* info: "++M1,5000),
@@ -358,8 +356,7 @@ formatter_fail(Config) ->
%% Check that handler is still alive and was never dead
Pid = whereis(h_proc_name(Name)),
- HC2 = logger:get_handler_config(),
- H = [Id || {Id,_,_} <- HC2],
+ H = logger:get_handler_ids(),
ok.
formatter_fail(cleanup,_Config) ->
@@ -1227,8 +1224,7 @@ start_handler(Name, FuncName, Config) ->
filters=>?DEFAULT_HANDLER_FILTERS([Name]),
formatter=>{?MODULE,op},
level => info}),
- {ok,{_,HConfig = #{config := DLHConfig}}} =
- logger:get_handler_config(Name),
+ {ok,HConfig = #{config := DLHConfig}} = logger:get_handler_config(Name),
{lists:concat([File,".1"]),HConfig,DLHConfig}.
stop_handler(Name) ->
diff --git a/lib/kernel/test/logger_env_var_SUITE.erl b/lib/kernel/test/logger_env_var_SUITE.erl
index fcdfcfd6d0..329b4c4b88 100644
--- a/lib/kernel/test/logger_env_var_SUITE.erl
+++ b/lib/kernel/test/logger_env_var_SUITE.erl
@@ -79,49 +79,49 @@ all() ->
default(Config) ->
{ok,#{handlers:=Hs},_Node} = setup(Config,[]),
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
StdFilters = maps:get(filters,StdC),
{domain,{_,{log,super,[otp,sasl]}}} = lists:keyfind(domain,1,StdFilters),
true = lists:keymember(stop_progress,1,StdFilters),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
ok.
default_sasl_compatible(Config) ->
{ok,#{handlers:=Hs},_Node} = setup(Config,
[{logger_sasl_compatible,true}]),
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
StdFilters = maps:get(filters,StdC),
{domain,{_,{log,super,[otp]}}} = lists:keyfind(domain,1,StdFilters),
false = lists:keymember(stop_progress,1,StdFilters),
- false = lists:keymember(simple,1,Hs),
- true = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ true = exists(sasl,Hs),
ok.
error_logger_tty(Config) ->
{ok,#{handlers:=Hs},_Node} = setup(Config,[{error_logger,tty}]),
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
StdFilters = maps:get(filters,StdC),
{domain,{_,{log,super,[otp,sasl]}}} = lists:keyfind(domain,1,StdFilters),
true = lists:keymember(stop_progress,1,StdFilters),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
ok.
error_logger_tty_sasl_compatible(Config) ->
{ok,#{handlers:=Hs},_Node} = setup(Config,
[{error_logger,tty},
{logger_sasl_compatible,true}]),
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
StdFilters = maps:get(filters,StdC),
{domain,{_,{log,super,[otp]}}} = lists:keyfind(domain,1,StdFilters),
false = lists:keymember(stop_progress,1,StdFilters),
- false = lists:keymember(simple,1,Hs),
- true = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ true = exists(sasl,Hs),
ok.
error_logger_false(Config) ->
@@ -129,14 +129,14 @@ error_logger_false(Config) ->
setup(Config,
[{error_logger,false},
{logger_level,notice}]),
- false = lists:keymember(?STANDARD_HANDLER,1,Hs),
- {simple,logger_simple_h,SimpleC} = lists:keyfind(simple,1,Hs),
+ false = exists(?STANDARD_HANDLER,Hs),
+ #{module:=logger_simple_h} = SimpleC = find(simple,Hs),
all = maps:get(level,SimpleC),
notice = maps:get(level,P),
SimpleFilters = maps:get(filters,SimpleC),
{domain,{_,{log,super,[otp,sasl]}}} = lists:keyfind(domain,1,SimpleFilters),
true = lists:keymember(stop_progress,1,SimpleFilters),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(sasl,Hs),
ok.
error_logger_false_progress(Config) ->
@@ -145,14 +145,14 @@ error_logger_false_progress(Config) ->
[{error_logger,false},
{logger_level,notice},
{logger_progress_reports,log}]),
- false = lists:keymember(?STANDARD_HANDLER,1,Hs),
- {simple,logger_simple_h,SimpleC} = lists:keyfind(simple,1,Hs),
+ false = exists(?STANDARD_HANDLER,Hs),
+ #{module:=logger_simple_h} = SimpleC = find(simple,Hs),
all = maps:get(level,SimpleC),
notice = maps:get(level,P),
SimpleFilters = maps:get(filters,SimpleC),
{domain,{_,{log,super,[otp,sasl]}}} = lists:keyfind(domain,1,SimpleFilters),
false = lists:keymember(stop_progress,1,SimpleFilters),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(sasl,Hs),
ok.
error_logger_false_sasl_compatible(Config) ->
@@ -161,38 +161,38 @@ error_logger_false_sasl_compatible(Config) ->
[{error_logger,false},
{logger_level,notice},
{logger_sasl_compatible,true}]),
- false = lists:keymember(?STANDARD_HANDLER,1,Hs),
- {simple,logger_simple_h,SimpleC} = lists:keyfind(simple,1,Hs),
+ false = exists(?STANDARD_HANDLER,Hs),
+ #{module:=logger_simple_h} = SimpleC = find(simple,Hs),
all = maps:get(level,SimpleC),
notice = maps:get(level,P),
SimpleFilters = maps:get(filters,SimpleC),
{domain,{_,{log,super,[otp]}}} = lists:keyfind(domain,1,SimpleFilters),
false = lists:keymember(stop_progress,1,SimpleFilters),
- true = lists:keymember(sasl,1,Hs),
+ true = exists(sasl,Hs),
ok.
error_logger_silent(Config) ->
{ok,#{handlers:=Hs},_Node} = setup(Config,
[{error_logger,silent}]),
- false = lists:keymember(?STANDARD_HANDLER,1,Hs),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(?STANDARD_HANDLER,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
ok.
error_logger_silent_sasl_compatible(Config) ->
{ok,#{handlers:=Hs},_Node} = setup(Config,
[{error_logger,silent},
{logger_sasl_compatible,true}]),
- false = lists:keymember(?STANDARD_HANDLER,1,Hs),
- false = lists:keymember(simple,1,Hs),
- true = lists:keymember(sasl,1,Hs),
+ false = exists(?STANDARD_HANDLER,Hs),
+ false = exists(simple,Hs),
+ true = exists(sasl,Hs),
ok.
error_logger_file(Config) ->
Log = file(Config,?FUNCTION_NAME),
- {ok,_Hs,Node} = setup(Config,
- [{error_logger,{file,Log}}]),
+ {ok,_,Node} = setup(Config,
+ [{error_logger,{file,Log}}]),
check_default_log(Node,Log,
file,% dest
0),% progress in std logger
@@ -210,13 +210,13 @@ logger_file(Config) ->
file,% dest
0),% progress in std logger
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
StdFilters = maps:get(filters,StdC),
{domain,{_,{log,super,[otp,sasl]}}} = lists:keyfind(domain,1,StdFilters),
true = lists:keymember(stop_progress,1,StdFilters),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
ok.
@@ -232,13 +232,13 @@ logger_file_sasl_compatible(Config) ->
file,% dest
0),% progress in std logger
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
StdFilters = maps:get(filters,StdC),
{domain,{_,{log,super,[otp]}}} = lists:keyfind(domain,1,StdFilters),
false = lists:keymember(stop_progress,1,StdFilters),
- false = lists:keymember(simple,1,Hs),
- true = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ true = exists(sasl,Hs),
ok.
@@ -254,13 +254,13 @@ logger_file_log_progress(Config) ->
file,% dest
6),% progress in std logger
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
StdFilters = maps:get(filters,StdC),
{domain,{_,{log,super,[otp,sasl]}}} = lists:keyfind(domain,1,StdFilters),
false = lists:keymember(stop_progress,1,StdFilters),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
ok.
@@ -276,11 +276,11 @@ logger_file_no_filter(Config) ->
file,% dest
6),% progress in std logger
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
[] = maps:get(filters,StdC),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
ok.
@@ -297,11 +297,11 @@ logger_file_no_filter_level(Config) ->
0,% progress in std logger
error),% level
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
error = maps:get(level,StdC),
[] = maps:get(filters,StdC),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
ok.
@@ -318,11 +318,11 @@ logger_file_formatter(Config) ->
file,% dest
6),% progress in std logger
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
[] = maps:get(filters,StdC),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
ok.
@@ -340,13 +340,13 @@ logger_filters(Config) ->
file,% dest
0),% progress in std logger
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
StdFilters = maps:get(filters,StdC),
{domain,{_,{log,super,[otp,sasl]}}} = lists:keyfind(domain,1,StdFilters),
false = lists:keymember(stop_progress,1,StdFilters),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
LoggerFilters = maps:get(filters,P),
true = lists:keymember(stop_progress,1,LoggerFilters),
@@ -368,11 +368,11 @@ logger_filters_stop(Config) ->
0,% progress in std logger
notice),
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
[] = maps:get(filters,StdC),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
LoggerFilters = maps:get(filters,P),
true = lists:keymember(log_error,1,LoggerFilters),
@@ -392,13 +392,13 @@ logger_module_level(Config) ->
file,% dest
3),% progress in std logger
- {?STANDARD_HANDLER,logger_std_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_std_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
StdFilters = maps:get(filters,StdC),
{domain,{_,{log,super,[otp,sasl]}}} = lists:keyfind(domain,1,StdFilters),
false = lists:keymember(stop_progress,1,StdFilters),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
[{supervisor,error}] = ModuleLevels,
ok.
@@ -413,13 +413,13 @@ logger_disk_log(Config) ->
disk_log,% dest
0),% progress in std logger
- {?STANDARD_HANDLER,logger_disk_log_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_disk_log_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
StdFilters = maps:get(filters,StdC),
{domain,{_,{log,super,[otp,sasl]}}} = lists:keyfind(domain,1,StdFilters),
true = lists:keymember(stop_progress,1,StdFilters),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
ok.
@@ -436,25 +436,25 @@ logger_disk_log_formatter(Config) ->
disk_log,% dest
6),% progress in std logger
- {?STANDARD_HANDLER,logger_disk_log_h,StdC} = lists:keyfind(?STANDARD_HANDLER,1,Hs),
+ #{module:=logger_disk_log_h} = StdC = find(?STANDARD_HANDLER,Hs),
all = maps:get(level,StdC),
[] = maps:get(filters,StdC),
- false = lists:keymember(simple,1,Hs),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(simple,Hs),
+ false = exists(sasl,Hs),
ok.
logger_undefined(Config) ->
{ok,#{handlers:=Hs,primary:=P},_Node} =
setup(Config,[{logger,[{handler,?STANDARD_HANDLER,undefined}]}]),
- false = lists:keymember(?STANDARD_HANDLER,1,Hs),
- {simple,logger_simple_h,SimpleC} = lists:keyfind(simple,1,Hs),
+ false = exists(?STANDARD_HANDLER,Hs),
+ #{module:=logger_simple_h} = SimpleC = find(simple,Hs),
all = maps:get(level,SimpleC),
info = maps:get(level,P),
SimpleFilters = maps:get(filters,SimpleC),
{domain,{_,{log,super,[otp,sasl]}}} = lists:keyfind(domain,1,SimpleFilters),
true = lists:keymember(stop_progress,1,SimpleFilters),
- false = lists:keymember(sasl,1,Hs),
+ false = exists(sasl,Hs),
ok.
@@ -535,10 +535,10 @@ logger_many_handlers(Config, Env, LogErr, LogInfo, NumProgress) ->
sasl_compatible_false(Config) ->
Log = file(Config,?FUNCTION_NAME),
- {ok,_Hs,Node} = setup(Config,
- [{error_logger,{file,Log}},
- {logger_sasl_compatible,false},
- {logger_progress_reports,log}]),
+ {ok,_,Node} = setup(Config,
+ [{error_logger,{file,Log}},
+ {logger_sasl_compatible,false},
+ {logger_progress_reports,log}]),
check_default_log(Node,Log,
file,% dest
6),% progress in std logger
@@ -546,10 +546,10 @@ sasl_compatible_false(Config) ->
sasl_compatible_false_no_progress(Config) ->
Log = file(Config,?FUNCTION_NAME),
- {ok,_Hs,Node} = setup(Config,
- [{error_logger,{file,Log}},
- {logger_sasl_compatible,false},
- {logger_progress_reports,stop}]),
+ {ok,_,Node} = setup(Config,
+ [{error_logger,{file,Log}},
+ {logger_sasl_compatible,false},
+ {logger_progress_reports,stop}]),
check_default_log(Node,Log,
file,% dest
0),% progress in std logger
@@ -557,9 +557,9 @@ sasl_compatible_false_no_progress(Config) ->
sasl_compatible(Config) ->
Log = file(Config,?FUNCTION_NAME),
- {ok,_Hs,Node} = setup(Config,
- [{error_logger,{file,Log}},
- {sasl_compatible,true}]),
+ {ok,_,Node} = setup(Config,
+ [{error_logger,{file,Log}},
+ {sasl_compatible,true}]),
check_default_log(Node,Log,
file,% dest
0),% progress in std logger
@@ -640,3 +640,21 @@ match(Bin,Pattern,N,LogLevel,ConfLevel) ->
{match,M} = re:run(Bin,Pattern,[{capture,all},global]),
N = length(M)
end.
+
+find(Id,Handlers) ->
+ case lists:search(fun(#{id:=Id0}) when Id0=:=Id-> true;
+ (_) -> false end,
+ Handlers) of
+ {value,Config} ->
+ Config;
+ false ->
+ false
+ end.
+
+exists(Id,Handlers) ->
+ case find(Id,Handlers) of
+ false ->
+ false;
+ _ ->
+ true
+ end.
diff --git a/lib/kernel/test/logger_std_h_SUITE.erl b/lib/kernel/test/logger_std_h_SUITE.erl
index 97b5c03a86..fd1840b9ff 100644
--- a/lib/kernel/test/logger_std_h_SUITE.erl
+++ b/lib/kernel/test/logger_std_h_SUITE.erl
@@ -55,7 +55,7 @@ suite() ->
init_per_suite(Config) ->
timer:start(), % to avoid progress report
- {ok,{logger_std_h,#{formatter:=OrigFormatter}}} =
+ {ok,#{formatter:=OrigFormatter}} =
logger:get_handler_config(?STANDARD_HANDLER),
[{formatter,OrigFormatter}|Config].
@@ -246,8 +246,7 @@ formatter_fail(Config) ->
true = lists:member(?MODULE,H),
%% Formatter is added automatically
- {ok,{_,#{formatter:={logger_formatter,_}}}} =
- logger:get_handler_config(?MODULE),
+ {ok,#{formatter:={logger_formatter,_}}} = logger:get_handler_config(?MODULE),
logger:info(M1=?msg,?domain),
Got1 = try_match_file(Log,"[0-9\\+\\-T:\\.]* info: "++M1,5000),
@@ -1151,8 +1150,7 @@ start_handler(Name, TTY, Config) when TTY == standard_io;
filter_default=>log,
filters=>?DEFAULT_HANDLER_FILTERS([Name]),
formatter=>{?MODULE,op}}),
- {ok,{_,HConfig = #{config := StdHConfig}}} =
- logger:get_handler_config(Name),
+ {ok,HConfig = #{config := StdHConfig}} = logger:get_handler_config(Name),
{HConfig,StdHConfig};
start_handler(Name, FuncName, Config) ->
@@ -1166,8 +1164,7 @@ start_handler(Name, FuncName, Config) ->
filter_default=>log,
filters=>?DEFAULT_HANDLER_FILTERS([Name]),
formatter=>{?MODULE,op}}),
- {ok,{_,HConfig = #{config := StdHConfig}}} =
- logger:get_handler_config(Name),
+ {ok,HConfig = #{config := StdHConfig}} = logger:get_handler_config(Name),
{Log,HConfig,StdHConfig}.
stop_handler(Name) ->