aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2018-06-05 20:03:21 +0200
committerSiri Hansen <[email protected]>2018-06-08 14:45:56 +0200
commit35c311607ed5b5a9ddea8c9a9be7c3b41845c737 (patch)
tree82a7e9ce68b267363ad391acc18fbac9bb4ea697 /lib/kernel/test
parent6f753ccf5178a809a7a26f692249bdfb5985335e (diff)
downloadotp-35c311607ed5b5a9ddea8c9a9be7c3b41845c737.tar.gz
otp-35c311607ed5b5a9ddea8c9a9be7c3b41845c737.tar.bz2
otp-35c311607ed5b5a9ddea8c9a9be7c3b41845c737.zip
[logger] Change concept of 'global' configuration to 'primary' configuration
Function names changed: get/set/update_logger_config -> get/set/update_primary_config add/remove_logger_filter -> add/remove_primary_filter
Diffstat (limited to 'lib/kernel/test')
-rw-r--r--lib/kernel/test/logger_SUITE.erl96
-rw-r--r--lib/kernel/test/logger_bench_SUITE.erl18
-rw-r--r--lib/kernel/test/logger_disk_log_h_SUITE.erl2
-rw-r--r--lib/kernel/test/logger_env_var_SUITE.erl24
4 files changed, 70 insertions, 70 deletions
diff --git a/lib/kernel/test/logger_SUITE.erl b/lib/kernel/test/logger_SUITE.erl
index 1057768eeb..bbf60cad74 100644
--- a/lib/kernel/test/logger_SUITE.erl
+++ b/lib/kernel/test/logger_SUITE.erl
@@ -63,7 +63,7 @@ end_per_group(_Group, _Config) ->
ok.
init_per_testcase(_TestCase, Config) ->
- {ok,LC} = logger:get_logger_config(),
+ {ok,LC} = logger:get_primary_config(),
[{logger_config,LC}|Config].
end_per_testcase(Case, Config) ->
@@ -155,11 +155,11 @@ multiple_handlers(cleanup,_Config) ->
add_remove_filter(_Config) ->
ok = logger:add_handler(h1,?MODULE,#{level=>info,filter_default=>log}),
LF = {fun(Log,_) -> Log#{level=>error} end, []},
- ok = logger:add_logger_filter(lf,LF),
- {error,{already_exist,lf}} = logger:add_logger_filter(lf,LF),
- {error,{already_exist,lf}} = logger:add_logger_filter(lf,{fun(Log,_) ->
- Log
- end, []}),
+ ok = logger:add_primary_filter(lf,LF),
+ {error,{already_exist,lf}} = logger:add_primary_filter(lf,LF),
+ {error,{already_exist,lf}} = logger:add_primary_filter(lf,{fun(Log,_) ->
+ Log
+ end, []}),
?LOG_INFO("hello",[]),
ok = check_logged(error,"hello",[],?MY_LOC(1)),
ok = check_no_log(),
@@ -180,8 +180,8 @@ add_remove_filter(_Config) ->
ok = check_logged(mylevel,"hello",[],?MY_LOC(1)),
ok = check_logged(error,"hello",[],?MY_LOC(2)),
- ok = logger:remove_logger_filter(lf),
- {error,{not_found,lf}} = logger:remove_logger_filter(lf),
+ ok = logger:remove_primary_filter(lf),
+ {error,{not_found,lf}} = logger:remove_primary_filter(lf),
?LOG_INFO("hello",[]),
ok = check_logged(info,"hello",[],?MY_LOC(1)),
@@ -203,7 +203,7 @@ add_remove_filter(_Config) ->
ok.
add_remove_filter(cleanup,_Config) ->
- logger:remove_logger_filter(lf),
+ logger:remove_primary_filter(lf),
logger:remove_handler(h1),
logger:remove_handler(h2),
ok.
@@ -241,30 +241,30 @@ change_config(_Config) ->
{ok,{_,C4}} = logger:get_handler_config(h1),
C4 = C3#{custom:=new_custom},
- %% Change logger config: Single key
- {ok,LConfig0} = logger:get_logger_config(),
- ok = logger:set_logger_config(level,warning),
- {ok,LConfig1} = logger:get_logger_config(),
+ %% Change primary config: Single key
+ {ok,LConfig0} = logger:get_primary_config(),
+ ok = logger:set_primary_config(level,warning),
+ {ok,LConfig1} = logger:get_primary_config(),
LConfig1 = LConfig0#{level:=warning},
- %% Change logger config: Map
- ok = logger:update_logger_config(#{level=>error}),
- {ok,LConfig2} = logger:get_logger_config(),
+ %% Change primary config: Map
+ ok = logger:update_primary_config(#{level=>error}),
+ {ok,LConfig2} = logger:get_primary_config(),
LConfig2 = LConfig1#{level:=error},
- %% Overwrite logger config - check that defaults are added
- ok = logger:set_logger_config(#{filter_default=>stop}),
+ %% Overwrite primary config - check that defaults are added
+ ok = logger:set_primary_config(#{filter_default=>stop}),
{ok,#{level:=info,filters:=[],filter_default:=stop}=LC1} =
- logger:get_logger_config(),
+ logger:get_primary_config(),
3 = maps:size(LC1),
%% 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,logger),
+ {ok,#{handlers:=HIds2}} = logger_config:get(?LOGGER_TABLE,primary),
HIds1 = lists:sort(HIds2),
%% Cleanup
- ok = logger:set_logger_config(LConfig0),
+ ok = logger:set_primary_config(LConfig0),
[] = test_server:messages_get(),
ok.
@@ -272,7 +272,7 @@ change_config(_Config) ->
change_config(cleanup,Config) ->
logger:remove_handler(h1),
LC = ?config(logger_config,Config),
- logger:set_logger_config(LC),
+ logger:set_primary_config(LC),
ok.
set_formatter(_Config) ->
@@ -298,11 +298,11 @@ log_no_levels(_Config) ->
ok = check_logged(notice,M1,#{}),
Levels = [emergency,alert,critical,error,warning,notice,info,debug],
- ok = logger:set_logger_config(level,none),
+ ok = logger:set_primary_config(level,none),
[logger:Level(#{Level=>rep}) || Level <- Levels],
ok = check_no_log(),
- ok = logger:set_logger_config(level,all),
+ ok = logger:set_primary_config(level,all),
M2 = ?map_rep,
?LOG_NOTICE(M2),
ok = check_logged(notice,M2,#{}),
@@ -329,12 +329,12 @@ log_no_levels(_Config) ->
ok.
log_no_levels(cleanup,_Config) ->
logger:remove_handler(h1),
- logger:set_logger_level(level,info),
+ logger:set_primary_config(level,info),
logger:unset_module_level(?MODULE),
ok.
log_all_levels_api(_Config) ->
- ok = logger:set_logger_config(level,all),
+ ok = logger:set_primary_config(level,all),
ok = logger:add_handler(h1,?MODULE,#{level=>all,filter_default=>log}),
test_api(emergency),
test_api(alert),
@@ -349,7 +349,7 @@ log_all_levels_api(_Config) ->
log_all_levels_api(cleanup,_Config) ->
logger:remove_handler(h1),
- logger:set_logger_config(level,info),
+ logger:set_primary_config(level,info),
ok.
macros(_Config) ->
@@ -368,14 +368,14 @@ set_level(_Config) ->
ok = check_no_log(),
logger:info(M1=?map_rep),
ok = check_logged(info,M1,#{}),
- ok = logger:set_logger_config(level,debug),
+ ok = logger:set_primary_config(level,debug),
logger:debug(M2=?map_rep),
ok = check_logged(debug,M2,#{}),
ok.
set_level(cleanup,_Config) ->
logger:remove_handler(h1),
- logger:set_logger_config(level,info),
+ logger:set_primary_config(level,info),
ok.
set_module_level(_Config) ->
@@ -424,13 +424,13 @@ set_module_level(cleanup,_Config) ->
cache_module_level(_Config) ->
ok = logger:unset_module_level(?MODULE),
- [] = ets:lookup(logger,?MODULE), %dirty - add API in logger_config?
+ [] = ets:lookup(?LOGGER_TABLE,?MODULE), %dirty - add API in logger_config?
?LOG_INFO(?map_rep),
%% Caching is done asynchronously, so wait a bit for the update
timer:sleep(100),
- [_] = ets:lookup(logger,?MODULE), %dirty - add API in logger_config?
+ [_] = ets:lookup(?LOGGER_TABLE,?MODULE), %dirty - add API in logger_config?
ok = logger:unset_module_level(?MODULE),
- [] = ets:lookup(logger,?MODULE), %dirty - add API in logger_config?
+ [] = ets:lookup(?LOGGER_TABLE,?MODULE), %dirty - add API in logger_config?
ok.
cache_module_level(cleanup,_Config) ->
@@ -468,18 +468,18 @@ filter_failed(_Config) ->
%% Logger filters
{error,{invalid_filter,_}} =
- logger:add_logger_filter(lf,{fun(_) -> ok end,args}),
- ok = logger:add_logger_filter(lf,{fun(_,_) -> a=b end,args}),
- {ok,#{filters:=[_]}} = logger:get_logger_config(),
+ 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(),
ok = logger:info(M1=?map_rep),
ok = check_logged(info,M1,#{}),
- {error,{not_found,lf}} = logger:remove_logger_filter(lf),
+ {error,{not_found,lf}} = logger:remove_primary_filter(lf),
- ok = logger:add_logger_filter(lf,{fun(_,_) -> faulty_return end,args}),
- {ok,#{filters:=[_]}} = logger:get_logger_config(),
+ ok = logger:add_primary_filter(lf,{fun(_,_) -> faulty_return end,args}),
+ {ok,#{filters:=[_]}} = logger:get_primary_config(),
ok = logger:info(M2=?map_rep),
ok = check_logged(info,M2,#{}),
- {error,{not_found,lf}} = logger:remove_logger_filter(lf),
+ {error,{not_found,lf}} = logger:remove_primary_filter(lf),
%% Handler filters
{error,{not_found,h0}} =
@@ -582,18 +582,18 @@ handler_failed(cleanup,_Config) ->
config_sanity_check(_Config) ->
%% Logger config
{error,{invalid_filter_default,bad}} =
- logger:set_logger_config(filter_default,bad),
- {error,{invalid_level,bad}} = logger:set_logger_config(level,bad),
- {error,{invalid_filters,bad}} = logger:set_logger_config(filters,bad),
- {error,{invalid_filter,bad}} = logger:set_logger_config(filters,[bad]),
+ logger:set_primary_config(filter_default,bad),
+ {error,{invalid_level,bad}} = logger:set_primary_config(level,bad),
+ {error,{invalid_filters,bad}} = logger:set_primary_config(filters,bad),
+ {error,{invalid_filter,bad}} = logger:set_primary_config(filters,[bad]),
{error,{invalid_filter,{_,_}}} =
- logger:set_logger_config(filters,[{id,bad}]),
+ logger:set_primary_config(filters,[{id,bad}]),
{error,{invalid_filter,{_,{_,_}}}} =
- logger:set_logger_config(filters,[{id,{bad,args}}]),
+ logger:set_primary_config(filters,[{id,{bad,args}}]),
{error,{invalid_filter,{_,{_,_}}}} =
- logger:set_logger_config(filters,[{id,{fun() -> ok end,args}}]),
- {error,{invalid_logger_config,{bad,bad}}} =
- logger:set_logger_config(bad,bad),
+ logger:set_primary_config(filters,[{id,{fun() -> ok end,args}}]),
+ {error,{invalid_primary_config,{bad,bad}}} =
+ logger:set_primary_config(bad,bad),
%% Handler config
{error,{not_found,h1}} = logger:set_handler_config(h1,a,b),
diff --git a/lib/kernel/test/logger_bench_SUITE.erl b/lib/kernel/test/logger_bench_SUITE.erl
index d47122ea9d..63fd4191af 100644
--- a/lib/kernel/test/logger_bench_SUITE.erl
+++ b/lib/kernel/test/logger_bench_SUITE.erl
@@ -181,16 +181,16 @@ log(Config) ->
log_drop(Config) ->
Times = ?TIMES*100,
- ok = logger:set_logger_config(level,error),
+ ok = logger:set_primary_config(level,error),
run_benchmark(Config,?FUNCTION_NAME,fun do_log_func/2, [info,?msg], Times).
log_drop(cleanup,_Config) ->
- ok = logger:set_logger_config(level,info).
+ ok = logger:set_primary_config(level,info).
log_drop_by_handler(Config) ->
Times = ?TIMES,
%% just ensure correct levels
- ok = logger:set_logger_config(level,info),
+ ok = logger:set_primary_config(level,info),
ok = logger:set_handler_config(?MODULE,level,error),
run_benchmark(Config,?FUNCTION_NAME,fun do_log_func/2, [info,?msg], Times).
@@ -209,16 +209,16 @@ macro(Config) ->
macro_drop(Config) ->
Times = ?TIMES*100,
- ok = logger:set_logger_config(level,error),
+ ok = logger:set_primary_config(level,error),
run_benchmark(Config,?FUNCTION_NAME,fun do_log_macro/2,[info,?msg], Times).
macro_drop(cleanup,_Config) ->
- ok = logger:set_logger_config(level,info).
+ ok = logger:set_primary_config(level,info).
macro_drop_by_handler(Config) ->
Times = ?TIMES,
%% just ensure correct levels
- ok = logger:set_logger_config(level,info),
+ ok = logger:set_primary_config(level,info),
ok = logger:set_handler_config(?MODULE,level,error),
run_benchmark(Config,?FUNCTION_NAME,fun do_log_macro/2, [info,?msg], Times).
@@ -237,16 +237,16 @@ error_logger(Config) ->
error_logger_drop(Config) ->
Times = ?TIMES*100,
- ok = logger:set_logger_config(level,error),
+ ok = logger:set_primary_config(level,error),
run_benchmark(Config,?FUNCTION_NAME,fun do_error_logger/2, [info,?msg], Times).
error_logger_drop(cleanup,_Config) ->
- ok = logger:set_logger_config(level,info).
+ ok = logger:set_primary_config(level,info).
error_logger_drop_by_handler(Config) ->
Times = ?TIMES,
%% just ensure correct levels
- ok = logger:set_logger_config(level,info),
+ ok = logger:set_primary_config(level,info),
ok = logger:set_handler_config(?MODULE,level,error),
run_benchmark(Config,?FUNCTION_NAME,fun do_log_func/2, [info,?msg], Times).
diff --git a/lib/kernel/test/logger_disk_log_h_SUITE.erl b/lib/kernel/test/logger_disk_log_h_SUITE.erl
index e1b1f16414..b2aa8fa51f 100644
--- a/lib/kernel/test/logger_disk_log_h_SUITE.erl
+++ b/lib/kernel/test/logger_disk_log_h_SUITE.erl
@@ -1323,7 +1323,7 @@ remove(Handler, LogName) ->
HState = #{log_names := Logs} = logger_disk_log_h:info(),
false = maps:is_key(LogName, HState),
false = lists:member(LogName, Logs),
- false = logger_config:exist(logger, LogName),
+ false = logger_config:exist(?LOGGER_TABLE, LogName),
{error,no_such_log} = disk_log:info(LogName),
ok.
diff --git a/lib/kernel/test/logger_env_var_SUITE.erl b/lib/kernel/test/logger_env_var_SUITE.erl
index f7f293c7fe..7ef6341377 100644
--- a/lib/kernel/test/logger_env_var_SUITE.erl
+++ b/lib/kernel/test/logger_env_var_SUITE.erl
@@ -125,14 +125,14 @@ error_logger_tty_sasl_compatible(Config) ->
ok.
error_logger_false(Config) ->
- {ok,#{handlers:=Hs,logger:=L},_Node} =
+ {ok,#{handlers:=Hs,primary:=P},_Node} =
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),
all = maps:get(level,SimpleC),
- notice = maps:get(level,L),
+ 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),
@@ -140,7 +140,7 @@ error_logger_false(Config) ->
ok.
error_logger_false_progress(Config) ->
- {ok,#{handlers:=Hs,logger:=L},_Node} =
+ {ok,#{handlers:=Hs,primary:=P},_Node} =
setup(Config,
[{error_logger,false},
{logger_level,notice},
@@ -148,7 +148,7 @@ error_logger_false_progress(Config) ->
false = lists:keymember(?STANDARD_HANDLER,1,Hs),
{simple,logger_simple_h,SimpleC} = lists:keyfind(simple,1,Hs),
all = maps:get(level,SimpleC),
- notice = maps:get(level,L),
+ 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),
@@ -156,7 +156,7 @@ error_logger_false_progress(Config) ->
ok.
error_logger_false_sasl_compatible(Config) ->
- {ok,#{handlers:=Hs,logger:=L},_Node} =
+ {ok,#{handlers:=Hs,primary:=P},_Node} =
setup(Config,
[{error_logger,false},
{logger_level,notice},
@@ -164,7 +164,7 @@ error_logger_false_sasl_compatible(Config) ->
false = lists:keymember(?STANDARD_HANDLER,1,Hs),
{simple,logger_simple_h,SimpleC} = lists:keyfind(simple,1,Hs),
all = maps:get(level,SimpleC),
- notice = maps:get(level,L),
+ 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),
@@ -328,7 +328,7 @@ logger_file_formatter(Config) ->
logger_filters(Config) ->
Log = file(Config,?FUNCTION_NAME),
- {ok,#{handlers:=Hs,logger:=Logger},Node}
+ {ok,#{handlers:=Hs,primary:=P},Node}
= setup(Config,
[{logger_progress_reports,log},
{logger,
@@ -347,14 +347,14 @@ logger_filters(Config) ->
false = lists:keymember(stop_progress,1,StdFilters),
false = lists:keymember(simple,1,Hs),
false = lists:keymember(sasl,1,Hs),
- LoggerFilters = maps:get(filters,Logger),
+ LoggerFilters = maps:get(filters,P),
true = lists:keymember(stop_progress,1,LoggerFilters),
ok.
logger_filters_stop(Config) ->
Log = file(Config,?FUNCTION_NAME),
- {ok,#{handlers:=Hs,logger:=Logger},Node}
+ {ok,#{handlers:=Hs,primary:=P},Node}
= setup(Config,
[{logger_progress_reports,log},
{logger,
@@ -373,7 +373,7 @@ logger_filters_stop(Config) ->
[] = maps:get(filters,StdC),
false = lists:keymember(simple,1,Hs),
false = lists:keymember(sasl,1,Hs),
- LoggerFilters = maps:get(filters,Logger),
+ LoggerFilters = maps:get(filters,P),
true = lists:keymember(log_error,1,LoggerFilters),
ok.
@@ -445,12 +445,12 @@ logger_disk_log_formatter(Config) ->
ok.
logger_undefined(Config) ->
- {ok,#{handlers:=Hs,logger:=L},_Node} =
+ {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),
all = maps:get(level,SimpleC),
- info = maps:get(level,L),
+ 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),