aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2018-06-05 20:50:01 +0200
committerSiri Hansen <[email protected]>2018-06-08 14:47:07 +0200
commit2ab3e91a44032cab2b173efc33b5d9589eec4864 (patch)
treea03c932a74f029a7d6a8e9dd5d348127e2975aed /lib/kernel/test
parent35c311607ed5b5a9ddea8c9a9be7c3b41845c737 (diff)
downloadotp-2ab3e91a44032cab2b173efc33b5d9589eec4864.tar.gz
otp-2ab3e91a44032cab2b173efc33b5d9589eec4864.tar.bz2
otp-2ab3e91a44032cab2b173efc33b5d9589eec4864.zip
[logger] Add more functions for reading configuration
Added: * logger:get_config() - replaces i(), returns all Logger configuration, i.e. primary and handler config, and module levels * logger:get_handler_ids() -> [HandlerId] * logger:get_handler_config() -> [{HandlerId,Module,Config}] Removed: * logger:i/1, will probably be replaced in a later release.
Diffstat (limited to 'lib/kernel/test')
-rw-r--r--lib/kernel/test/logger_SUITE.erl44
-rw-r--r--lib/kernel/test/logger_bench_SUITE.erl2
-rw-r--r--lib/kernel/test/logger_disk_log_h_SUITE.erl4
-rw-r--r--lib/kernel/test/logger_simple_h_SUITE.erl2
-rw-r--r--lib/kernel/test/logger_std_h_SUITE.erl6
-rw-r--r--lib/kernel/test/logger_test_lib.erl2
6 files changed, 29 insertions, 31 deletions
diff --git a/lib/kernel/test/logger_SUITE.erl b/lib/kernel/test/logger_SUITE.erl
index bbf60cad74..c24738718e 100644
--- a/lib/kernel/test/logger_SUITE.erl
+++ b/lib/kernel/test/logger_SUITE.erl
@@ -63,8 +63,8 @@ end_per_group(_Group, _Config) ->
ok.
init_per_testcase(_TestCase, Config) ->
- {ok,LC} = logger:get_primary_config(),
- [{logger_config,LC}|Config].
+ PC = logger:get_primary_config(),
+ [{logger_config,PC}|Config].
end_per_testcase(Case, Config) ->
try apply(?MODULE,Case,[cleanup,Config])
@@ -106,11 +106,11 @@ start_stop(_Config) ->
add_remove_handler(_Config) ->
register(callback_receiver,self()),
- #{handlers:=Hs0} = logger:i(),
+ Hs0 = logger:get_handler_config(),
{error,{not_found,h1}} = logger:get_handler_config(h1),
ok = logger:add_handler(h1,?MODULE,#{}),
[add] = test_server:messages_get(),
- #{handlers:=Hs} = logger:i(),
+ Hs = logger:get_handler_config(),
{value,_,Hs0} = lists:keytake(h1,1,Hs),
{ok,{?MODULE,#{level:=all,filters:=[],filter_default:=log}}} = % defaults
logger:get_handler_config(h1),
@@ -125,7 +125,7 @@ add_remove_handler(_Config) ->
ok = check_logged(info,"hello",[],?MY_LOC(1)),
ok = logger:remove_handler(h1),
[remove] = test_server:messages_get(),
- #{handlers:=Hs0} = logger:i(),
+ Hs0 = logger:get_handler_config(),
{error,{not_found,h1}} = logger:get_handler_config(h1),
{error,{not_found,h1}} = logger:remove_handler(h1),
logger:info("hello",[]),
@@ -242,37 +242,37 @@ change_config(_Config) ->
C4 = C3#{custom:=new_custom},
%% Change primary config: Single key
- {ok,LConfig0} = logger:get_primary_config(),
+ PConfig0 = logger:get_primary_config(),
ok = logger:set_primary_config(level,warning),
- {ok,LConfig1} = logger:get_primary_config(),
- LConfig1 = LConfig0#{level:=warning},
+ PConfig1 = logger:get_primary_config(),
+ PConfig1 = PConfig0#{level:=warning},
%% Change primary config: Map
ok = logger:update_primary_config(#{level=>error}),
- {ok,LConfig2} = logger:get_primary_config(),
- LConfig2 = LConfig1#{level:=error},
+ PConfig2 = logger:get_primary_config(),
+ PConfig2 = PConfig1#{level:=error},
%% Overwrite primary config - check that defaults are added
ok = logger:set_primary_config(#{filter_default=>stop}),
- {ok,#{level:=info,filters:=[],filter_default:=stop}=LC1} =
+ #{level:=info,filters:=[],filter_default:=stop}=PC1 =
logger:get_primary_config(),
- 3 = maps:size(LC1),
+ 3 = maps:size(PC1),
%% Check that internal 'handlers' field has not been changed
- #{handlers:=HCs} = logger:i(),
- HIds1 = [Id || {Id,_,_} <- HCs],
- {ok,#{handlers:=HIds2}} = logger_config:get(?LOGGER_TABLE,primary),
+ MS = [{{{?HANDLER_KEY,'$1'},'_','_','_'},[],['$1']}],
+ HIds1 = ets:select(?LOGGER_TABLE,MS), % dirty, checking internal data
+ HIds2 = logger:get_handler_ids(),
HIds1 = lists:sort(HIds2),
%% Cleanup
- ok = logger:set_primary_config(LConfig0),
+ ok = logger:set_primary_config(PConfig0),
[] = test_server:messages_get(),
ok.
change_config(cleanup,Config) ->
logger:remove_handler(h1),
- LC = ?config(logger_config,Config),
- logger:set_primary_config(LC),
+ PC = ?config(logger_config,Config),
+ logger:set_primary_config(PC),
ok.
set_formatter(_Config) ->
@@ -470,13 +470,13 @@ filter_failed(_Config) ->
{error,{invalid_filter,_}} =
logger:add_primary_filter(lf,{fun(_) -> ok end,args}),
ok = logger:add_primary_filter(lf,{fun(_,_) -> a=b end,args}),
- {ok,#{filters:=[_]}} = logger:get_primary_config(),
+ #{filters:=[_]} = logger:get_primary_config(),
ok = logger:info(M1=?map_rep),
ok = check_logged(info,M1,#{}),
{error,{not_found,lf}} = logger:remove_primary_filter(lf),
ok = logger:add_primary_filter(lf,{fun(_,_) -> faulty_return end,args}),
- {ok,#{filters:=[_]}} = logger:get_primary_config(),
+ #{filters:=[_]} = logger:get_primary_config(),
ok = logger:info(M2=?map_rep),
ok = check_logged(info,M2,#{}),
{error,{not_found,lf}} = logger:remove_primary_filter(lf),
@@ -519,7 +519,7 @@ handler_failed(_Config) ->
{error,{invalid_handler,_}} = logger:add_handler(h1,nomodule,#{filter_default=>log}),
logger:info(?map_rep),
check_no_log(),
- #{handlers:=H1} = logger:i(),
+ H1 = logger:get_handler_config(),
false = lists:keymember(h1,1,H1),
{error,{not_found,h1}} = logger:remove_handler(h1),
@@ -529,7 +529,7 @@ handler_failed(_Config) ->
logger:info(?map_rep),
[remove] = test_server:messages_get(),
- #{handlers:=H2} = logger:i(),
+ H2 = logger:get_handler_config(),
false = lists:keymember(h2,1,H2),
{error,{not_found,h2}} = logger:remove_handler(h2),
diff --git a/lib/kernel/test/logger_bench_SUITE.erl b/lib/kernel/test/logger_bench_SUITE.erl
index 63fd4191af..5ac0ace41b 100644
--- a/lib/kernel/test/logger_bench_SUITE.erl
+++ b/lib/kernel/test/logger_bench_SUITE.erl
@@ -365,7 +365,7 @@ calc_and_report(Config,Tag,MSecs,Times) ->
{save_config,[{bench,[{Tag,IOPS,MSecs}|Bench]}]}.
remove_all_handlers() ->
- #{handlers:=Hs} = logger:i(),
+ Hs = logger:get_handler_config(),
[logger:remove_handler(Id) || {Id,_,_} <- Hs],
Hs.
diff --git a/lib/kernel/test/logger_disk_log_h_SUITE.erl b/lib/kernel/test/logger_disk_log_h_SUITE.erl
index b2aa8fa51f..4fada8ab3a 100644
--- a/lib/kernel/test/logger_disk_log_h_SUITE.erl
+++ b/lib/kernel/test/logger_disk_log_h_SUITE.erl
@@ -328,7 +328,7 @@ formatter_fail(Config) ->
logger:add_handler(Name, logger_disk_log_h, HConfig),
Pid = whereis(h_proc_name(Name)),
true = is_pid(Pid),
- #{handlers:=HC1} = logger:i(),
+ HC1 = logger:get_handler_config(),
H = [Id || {Id,_,_} <- HC1],
true = lists:member(Name,H),
@@ -358,7 +358,7 @@ formatter_fail(Config) ->
%% Check that handler is still alive and was never dead
Pid = whereis(h_proc_name(Name)),
- #{handlers:=HC2} = logger:i(),
+ HC2 = logger:get_handler_config(),
H = [Id || {Id,_,_} <- HC2],
ok.
diff --git a/lib/kernel/test/logger_simple_h_SUITE.erl b/lib/kernel/test/logger_simple_h_SUITE.erl
index 271a2126de..264cddb069 100644
--- a/lib/kernel/test/logger_simple_h_SUITE.erl
+++ b/lib/kernel/test/logger_simple_h_SUITE.erl
@@ -48,7 +48,7 @@ suite() ->
{ct_hooks, [logger_test_lib]}].
init_per_suite(Config) ->
- #{handlers:=Hs0} = logger:i(),
+ Hs0 = logger:get_handler_config(),
Hs = lists:keydelete(cth_log_redirect,1,Hs0),
[ok = logger:remove_handler(Id) || {Id,_,_} <- Hs],
Env = [{App,Key,application:get_env(App,Key)} ||
diff --git a/lib/kernel/test/logger_std_h_SUITE.erl b/lib/kernel/test/logger_std_h_SUITE.erl
index fa90be0fc8..332d58eac8 100644
--- a/lib/kernel/test/logger_std_h_SUITE.erl
+++ b/lib/kernel/test/logger_std_h_SUITE.erl
@@ -242,8 +242,7 @@ formatter_fail(Config) ->
filters=>?DEFAULT_HANDLER_FILTERS([?MODULE])}),
Pid = whereis(h_proc_name()),
true = is_pid(Pid),
- #{handlers:=HC1} = logger:i(),
- H = [Id || {Id,_,_} <- HC1],
+ H = logger:get_handler_ids(),
true = lists:member(?MODULE,H),
%% Formatter is added automatically
@@ -272,8 +271,7 @@ formatter_fail(Config) ->
%% Check that handler is still alive and was never dead
Pid = whereis(h_proc_name()),
- #{handlers:=HC2} = logger:i(),
- H = [Id || {Id,_,_} <- HC2],
+ H = logger:get_handler_ids(),
ok.
diff --git a/lib/kernel/test/logger_test_lib.erl b/lib/kernel/test/logger_test_lib.erl
index 5ad6336925..9097453c10 100644
--- a/lib/kernel/test/logger_test_lib.erl
+++ b/lib/kernel/test/logger_test_lib.erl
@@ -37,7 +37,7 @@ setup(Config,Vars) ->
" -boot start_sasl -kernel start_timer true "
"-config ",ConfigFileName]}]) of
{ok, Node} ->
- L = rpc:call(Node, logger, i, []),
+ L = rpc:call(Node, logger, get_config, []),
ct:log("~p",[L]),
{ok, L, Node};
{error, Reason} ->