aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2018-06-07 11:47:05 +0200
committerSiri Hansen <[email protected]>2018-06-08 14:48:14 +0200
commitf20c281be6fa27e2da1c543a64029531c5f00325 (patch)
tree531da0cc6860757a7fce868a2b4b484b5c685055 /lib/kernel/src
parent7f6e61ca0d752c780ffadd7aacf29aaab0783c78 (diff)
downloadotp-f20c281be6fa27e2da1c543a64029531c5f00325.tar.gz
otp-f20c281be6fa27e2da1c543a64029531c5f00325.tar.bz2
otp-f20c281be6fa27e2da1c543a64029531c5f00325.zip
[logger] Update return values from get_handler_config/0,1 and get_config/0
Module and Id are now always included as fields in Config, so these are no longer returned as separate elements.
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/error_logger.erl4
-rw-r--r--lib/kernel/src/logger.erl20
-rw-r--r--lib/kernel/src/logger_h_common.erl2
-rw-r--r--lib/kernel/src/logger_server.erl11
4 files changed, 20 insertions, 17 deletions
diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl
index 3bdd70fa96..ef930317b1 100644
--- a/lib/kernel/src/error_logger.erl
+++ b/lib/kernel/src/error_logger.erl
@@ -513,7 +513,7 @@ tty(true) ->
_ = case lists:member(error_logger_tty_h, which_report_handlers()) of
false ->
case logger:get_handler_config(default) of
- {ok,{logger_std_h,#{config:=#{type:=standard_io}}}} ->
+ {ok,#{module:=logger_std_h,config:=#{type:=standard_io}}} ->
logger:remove_handler_filter(default,
error_logger_tty_false);
_ ->
@@ -533,7 +533,7 @@ tty(false) ->
delete_report_handler(error_logger_tty_h),
_ = logger:remove_handler(error_logger_tty_true),
_ = case logger:get_handler_config(default) of
- {ok,{logger_std_h,#{config:=#{type:=standard_io}}}} ->
+ {ok,#{module:=logger_std_h,config:=#{type:=standard_io}}} ->
logger:add_handler_filter(default,error_logger_tty_false,
{fun(_,_) -> stop end, ok});
_ ->
diff --git a/lib/kernel/src/logger.erl b/lib/kernel/src/logger.erl
index df7ce22e2a..f6dc8ea397 100644
--- a/lib/kernel/src/logger.erl
+++ b/lib/kernel/src/logger.erl
@@ -390,21 +390,23 @@ get_primary_config() ->
{ok,Config} = logger_config:get(?LOGGER_TABLE,primary),
maps:remove(handlers,Config).
--spec get_handler_config(HandlerId) -> {ok,{Module,Config}} | {error,term()} when
+-spec get_handler_config(HandlerId) -> {ok,Config} | {error,term()} when
HandlerId :: handler_id(),
- Module :: module(),
Config :: config().
get_handler_config(HandlerId) ->
- logger_config:get(?LOGGER_TABLE,HandlerId).
+ case logger_config:get(?LOGGER_TABLE,HandlerId) of
+ {ok,{_,Config}} ->
+ {ok,Config};
+ Error ->
+ Error
+ end.
--spec get_handler_config() -> [{HandlerId,Module,Config}] when
- HandlerId :: handler_id(),
- Module :: module(),
+-spec get_handler_config() -> [Config] when
Config :: config().
get_handler_config() ->
[begin
- {ok,{Module,Config}} = get_handler_config(HandlerId),
- {HandlerId,Module,Config}
+ {ok,Config} = get_handler_config(HandlerId),
+ Config
end || HandlerId <- get_handler_ids()].
-spec get_handler_ids() -> [HandlerId] when
@@ -511,7 +513,7 @@ unset_process_metadata() ->
ok.
-spec get_config() -> #{primary=>config(),
- handlers=>[{handler_id(),module(),config()}],
+ handlers=>[config()],
module_levels=>[{module(),level() | all | none}]}.
get_config() ->
#{primary=>get_primary_config(),
diff --git a/lib/kernel/src/logger_h_common.erl b/lib/kernel/src/logger_h_common.erl
index 73a5b27ea1..2a935328aa 100644
--- a/lib/kernel/src/logger_h_common.erl
+++ b/lib/kernel/src/logger_h_common.erl
@@ -266,7 +266,7 @@ stop_or_restart(Name, {shutdown,Reason={overloaded,_Name,_QLen,_Mem}},
exit(HandlerPid, kill)
end,
case logger:get_handler_config(Name) of
- {ok,{HMod,HConfig}} when is_integer(RestartAfter) ->
+ {ok,#{module:=HMod}=HConfig} when is_integer(RestartAfter) ->
_ = logger:remove_handler(Name),
_ = timer:apply_after(RestartAfter, logger, add_handler,
[Name,HMod,HConfig]);
diff --git a/lib/kernel/src/logger_server.erl b/lib/kernel/src/logger_server.erl
index 7df762053e..6d4ab0925d 100644
--- a/lib/kernel/src/logger_server.erl
+++ b/lib/kernel/src/logger_server.erl
@@ -107,10 +107,9 @@ cache_module_level(Module) ->
set_config(Owner,Key,Value) ->
update_config(Owner,#{Key=>Value}).
-set_config(Owner,Config0) ->
- case sanity_check(Owner,Config0) of
+set_config(Owner,Config) ->
+ case sanity_check(Owner,Config) of
ok ->
- Config = maps:merge(default_config(Owner),Config0),
call({set_config,Owner,Config});
Error ->
Error
@@ -215,13 +214,15 @@ handle_call({update_config,Id,NewConfig}, From, #state{tid=Tid}=State) ->
Error ->
{reply,Error,State}
end;
-handle_call({set_config,primary,Config}, _From, #state{tid=Tid}=State) ->
+handle_call({set_config,primary,Config0}, _From, #state{tid=Tid}=State) ->
+ Config = maps:merge(default_config(primary),Config0),
{ok,#{handlers:=Handlers}} = logger_config:get(Tid,primary),
Reply = do_set_config(Tid,primary,Config#{handlers=>Handlers}),
{reply,Reply,State};
-handle_call({set_config,HandlerId,Config}, From, #state{tid=Tid}=State) ->
+handle_call({set_config,HandlerId,Config0}, From, #state{tid=Tid}=State) ->
case logger_config:get(Tid,HandlerId) of
{ok,{Module,OldConfig}} ->
+ Config = maps:merge(default_config(HandlerId,Module),Config0),
call_h_async(
fun() ->
call_h(Module,changing_config,[OldConfig,Config],