aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/error_logger.erl6
-rw-r--r--lib/kernel/src/logger.erl4
-rw-r--r--lib/kernel/src/logger_disk_log_h.erl30
-rw-r--r--lib/kernel/src/logger_server.erl6
-rw-r--r--lib/kernel/src/logger_std_h.erl30
5 files changed, 40 insertions, 36 deletions
diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl
index 4b3922cdd7..3bdd70fa96 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,#{logger_std_h:=#{type:=standard_io}}}} ->
+ {ok,{logger_std_h,#{config:=#{type:=standard_io}}}} ->
logger:remove_handler_filter(default,
error_logger_tty_false);
_ ->
@@ -523,7 +523,7 @@ tty(true) ->
[otp]),
formatter=>{?DEFAULT_FORMATTER,
?DEFAULT_FORMAT_CONFIG},
- logger_std_h=>#{type=>standard_io}})
+ config=>#{type=>standard_io}})
end;
true ->
ok
@@ -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,#{logger_std_h:=#{type:=standard_io}}}} ->
+ {ok,{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 b251b21bff..df7ce22e2a 100644
--- a/lib/kernel/src/logger.erl
+++ b/lib/kernel/src/logger.erl
@@ -96,7 +96,9 @@
-type filter_arg() :: term().
-type filter_return() :: stop | ignore | log_event().
-type config() :: #{id => handler_id(),
+ config => map(),
level => level() | all | none,
+ module => module(),
filter_default => log | stop,
filters => [{filter_id(),filter()}],
formatter => {module(),formatter_config()},
@@ -673,7 +675,7 @@ init_default_config(Type) when Type==standard_io;
element(1,Type)==file ->
Env = get_logger_env(),
DefaultFormatter = #{formatter=>{?DEFAULT_FORMATTER,?DEFAULT_FORMAT_CONFIG}},
- DefaultConfig = DefaultFormatter#{logger_std_h=>#{type=>Type}},
+ DefaultConfig = DefaultFormatter#{config=>#{type=>Type}},
NewLoggerEnv =
case lists:keyfind(default, 2, Env) of
{handler, default, Module, Config} ->
diff --git a/lib/kernel/src/logger_disk_log_h.erl b/lib/kernel/src/logger_disk_log_h.erl
index ba90fefcd3..d339957ac8 100644
--- a/lib/kernel/src/logger_disk_log_h.erl
+++ b/lib/kernel/src/logger_disk_log_h.erl
@@ -115,7 +115,7 @@ adding_handler(#{id:=Name}=Config) ->
case check_config(adding, Config) of
{ok, Config1} ->
%% create initial handler state by merging defaults with config
- HConfig = maps:get(?MODULE, Config1, #{}),
+ HConfig = maps:get(config, Config1, #{}),
HState = maps:merge(get_init_state(), HConfig),
case logger_h_common:overload_levels_ok(HState) of
true ->
@@ -139,15 +139,15 @@ adding_handler(#{id:=Name}=Config) ->
%%%-----------------------------------------------------------------
%%% Updating handler config
-changing_config(OldConfig=#{id:=Name, disk_log_opts:=DLOpts, ?MODULE:=HConfig},
+changing_config(OldConfig=#{id:=Name, disk_log_opts:=DLOpts, config:=HConfig},
NewConfig=#{id:=Name, disk_log_opts:=DLOpts}) ->
case check_config(changing, NewConfig) of
- {ok,NewConfig1 = #{?MODULE:=NewHConfig}} ->
+ {ok,NewConfig1 = #{config:=NewHConfig}} ->
#{handler_pid:=HPid,
mode_tab:=ModeTab} = HConfig,
NewHConfig1 = NewHConfig#{handler_pid=>HPid,
mode_tab=>ModeTab},
- NewConfig2 = NewConfig1#{?MODULE=>NewHConfig1},
+ NewConfig2 = NewConfig1#{config=>NewHConfig1},
try gen_server:call(HPid, {change_config,OldConfig,NewConfig2},
?DEFAULT_CALL_TIMEOUT) of
ok -> {ok,NewConfig2};
@@ -167,11 +167,11 @@ check_config(adding, #{id:=Name}=Config) ->
LogOpts = merge_default_logopts(Name, LogOpts0),
case check_log_opts(maps:to_list(LogOpts)) of
ok ->
- MyConfig = maps:get(?MODULE, Config, #{}),
+ MyConfig = maps:get(config, Config, #{}),
case check_my_config(maps:to_list(MyConfig)) of
ok ->
{ok,Config#{disk_log_opts=>LogOpts,
- ?MODULE=>MyConfig}};
+ config=>MyConfig}};
Error ->
Error
end;
@@ -179,7 +179,7 @@ check_config(adding, #{id:=Name}=Config) ->
Error
end;
check_config(changing, Config) ->
- MyConfig = maps:get(?MODULE, Config, #{}),
+ MyConfig = maps:get(config, Config, #{}),
case check_my_config(maps:to_list(MyConfig)) of
ok -> {ok,Config};
Error -> Error
@@ -248,8 +248,8 @@ swap_buffer(Name, Buffer) ->
Config :: logger:config().
log(LogEvent, Config = #{id := Name,
- ?MODULE := #{handler_pid := HPid,
- mode_tab := ModeTab}}) ->
+ config := #{handler_pid := HPid,
+ mode_tab := ModeTab}}) ->
%% if the handler has crashed, we must drop this request
%% and hope the handler restarts so we can try again
true = is_process_alive(HPid),
@@ -260,7 +260,7 @@ log(LogEvent, Config = #{id := Name,
%%% gen_server callbacks
%%%===================================================================
-init([Name, Config = #{?MODULE := HConfig, disk_log_opts := LogOpts},
+init([Name, Config = #{config := HConfig, disk_log_opts := LogOpts},
State = #{dl_sync_int := DLSyncInt}]) ->
register(?name_to_reg_name(?MODULE,Name), self()),
process_flag(trap_exit, true),
@@ -291,8 +291,8 @@ init([Name, Config = #{?MODULE := HConfig, disk_log_opts := LogOpts},
prev_sync_result => ok,
prev_disk_log_info => undefined}),
Config1 =
- Config#{?MODULE => HConfig#{handler_pid => self(),
- mode_tab => ModeTab}},
+ Config#{config => HConfig#{handler_pid => self(),
+ mode_tab => ModeTab}},
proc_lib:init_ack({ok,self(),Config1}),
gen_server:cast(self(), repeated_disk_log_sync),
enter_loop(Config1, State1)
@@ -335,7 +335,7 @@ handle_call(disk_log_sync, _From, State = #{id := Name}) ->
handle_call({change_config,_OldConfig,NewConfig}, _From,
State = #{filesync_repeat_interval := FSyncInt0}) ->
- HConfig = maps:get(?MODULE, NewConfig, #{}),
+ HConfig = maps:get(config, NewConfig, #{}),
State1 = #{toggle_sync_qlen := TSQL,
drop_new_reqs_qlen := DNRQL,
flush_reqs_qlen := FRQL} = maps:merge(State, HConfig),
@@ -482,9 +482,9 @@ get_init_state() ->
%%% ignored.
%%%
%%% Handler specific config should be provided with a sub map associated
-%%% with a key named the same as this module, e.g:
+%%% with a key named 'config', e.g:
%%%
-%%% Config = #{logger_disk_log_h => #{toggle_sync_qlen => 50}
+%%% Config = #{config => #{toggle_sync_qlen => 50}
%%%
%%% The disk_log handler process is linked to logger_sup, which is
%%% part of the kernel application's supervision tree.
diff --git a/lib/kernel/src/logger_server.erl b/lib/kernel/src/logger_server.erl
index c7d386ab82..7df762053e 100644
--- a/lib/kernel/src/logger_server.erl
+++ b/lib/kernel/src/logger_server.erl
@@ -53,7 +53,7 @@ add_handler(Id,Module,Config0) ->
{ok,ok} ->
case sanity_check(Id,Config0) of
ok ->
- Default = default_config(Id),
+ Default = default_config(Id,Module),
Config = maps:merge(Default,Config0),
call({add_handler,Id,Module,Config});
Error ->
@@ -141,7 +141,7 @@ init([]) ->
PrimaryConfig = maps:merge(default_config(primary),
#{handlers=>[simple]}),
logger_config:create(Tid,primary,PrimaryConfig),
- SimpleConfig0 = maps:merge(default_config(simple),
+ SimpleConfig0 = maps:merge(default_config(simple,logger_simple_h),
#{filter_default=>stop,
filters=>?DEFAULT_HANDLER_FILTERS}),
%% If this fails, then the node should crash
@@ -365,6 +365,8 @@ default_config(Id) ->
filters=>[],
filter_default=>log,
formatter=>{?DEFAULT_FORMATTER,#{}}}.
+default_config(Id,Module) ->
+ (default_config(Id))#{module=>Module}.
sanity_check(Owner,Key,Value) ->
sanity_check_1(Owner,[{Key,Value}]).
diff --git a/lib/kernel/src/logger_std_h.erl b/lib/kernel/src/logger_std_h.erl
index 5ec9eced12..bebd5300b4 100644
--- a/lib/kernel/src/logger_std_h.erl
+++ b/lib/kernel/src/logger_std_h.erl
@@ -116,7 +116,7 @@ adding_handler(#{id:=Name}=Config) ->
case check_config(adding, Config) of
{ok, Config1} ->
%% create initial handler state by merging defaults with config
- HConfig = maps:get(?MODULE, Config1, #{}),
+ HConfig = maps:get(config, Config1, #{}),
HState = maps:merge(get_init_state(), HConfig),
case logger_h_common:overload_levels_ok(HState) of
true ->
@@ -140,17 +140,17 @@ adding_handler(#{id:=Name}=Config) ->
%%%-----------------------------------------------------------------
%%% Updating handler config
-changing_config(OldConfig=#{id:=Name, ?MODULE:=HConfig},
+changing_config(OldConfig=#{id:=Name, config:=HConfig},
NewConfig=#{id:=Name}) ->
#{type:=Type, handler_pid:=HPid, mode_tab:=ModeTab} = HConfig,
- MyConfig = maps:get(?MODULE, NewConfig, #{}),
+ MyConfig = maps:get(config, NewConfig, #{}),
case maps:get(type, MyConfig, Type) of
Type ->
MyConfig1 = MyConfig#{type=>Type,
handler_pid=>HPid,
mode_tab=>ModeTab},
changing_config1(HPid, OldConfig,
- NewConfig#{?MODULE=>MyConfig1});
+ NewConfig#{config=>MyConfig1});
_ ->
{error,{illegal_config_change,OldConfig,NewConfig}}
end;
@@ -173,17 +173,17 @@ changing_config1(HPid, OldConfig, NewConfig) ->
check_config(adding, Config) ->
%% Merge in defaults on handler level
- MyConfig0 = maps:get(?MODULE, Config, #{}),
+ MyConfig0 = maps:get(config, Config, #{}),
MyConfig = maps:merge(#{type => standard_io},
MyConfig0),
case check_my_config(maps:to_list(MyConfig)) of
ok ->
- {ok,Config#{?MODULE=>MyConfig}};
+ {ok,Config#{config=>MyConfig}};
Error ->
Error
end;
check_config(changing, Config) ->
- MyConfig = maps:get(?MODULE, Config, #{}),
+ MyConfig = maps:get(config, Config, #{}),
case check_my_config(maps:to_list(MyConfig)) of
ok -> {ok,Config};
Error -> Error
@@ -230,8 +230,8 @@ swap_buffer(Name, Buffer) ->
Config :: logger:config().
log(LogEvent, Config = #{id := Name,
- ?MODULE := #{handler_pid := HPid,
- mode_tab := ModeTab}}) ->
+ config := #{handler_pid := HPid,
+ mode_tab := ModeTab}}) ->
%% if the handler has crashed, we must drop this request
%% and hope the handler restarts so we can try again
true = is_process_alive(HPid),
@@ -242,7 +242,7 @@ log(LogEvent, Config = #{id := Name,
%%% gen_server callbacks
%%%===================================================================
-init([Name, Config = #{?MODULE := HConfig},
+init([Name, Config = #{config := HConfig},
State0 = #{type := Type, file_ctrl_sync_int := FileCtrlSyncInt}]) ->
register(?name_to_reg_name(?MODULE,Name), self()),
process_flag(trap_exit, true),
@@ -269,8 +269,8 @@ init([Name, Config = #{?MODULE := HConfig},
burst_win_ts => T0,
burst_msg_count => 0}),
Config1 =
- Config#{?MODULE => HConfig#{handler_pid => self(),
- mode_tab => ModeTab}},
+ Config#{config => HConfig#{handler_pid => self(),
+ mode_tab => ModeTab}},
proc_lib:init_ack({ok,self(),Config1}),
gen_server:cast(self(), repeated_filesync),
enter_loop(Config1, State1)
@@ -332,7 +332,7 @@ handle_call(filesync, _From, State = #{type := Type,
handle_call({change_config,_OldConfig,NewConfig}, _From,
State = #{filesync_repeat_interval := FSyncInt0}) ->
- HConfig = maps:get(?MODULE, NewConfig, #{}),
+ HConfig = maps:get(config, NewConfig, #{}),
State1 = maps:merge(State, HConfig),
case logger_h_common:overload_levels_ok(State1) of
true ->
@@ -470,9 +470,9 @@ get_init_state() ->
%%% exist if the handler is not registered).
%%%
%%% Handler specific config should be provided with a sub map associated
-%%% with a key named the same as this module, e.g:
+%%% with a key named 'config', e.g:
%%%
-%%% Config = #{logger_std_h => #{toggle_sync_qlen => 50}
+%%% Config = #{config => #{toggle_sync_qlen => 50}
%%%
%%% The standard handler process is linked to logger_sup, which is
%%% part of the kernel application's supervision tree.