25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

Report errors in logger initialization

This commit is contained in:
Evgeny Khramtsov 2019-10-23 16:03:48 +03:00
parent 86bb77bfc2
commit 1e30b85861

View File

@ -110,19 +110,32 @@ start(Level) ->
single_line => false}, single_line => false},
FileFmtConfig = FmtConfig#{template => file_template()}, FileFmtConfig = FmtConfig#{template => file_template()},
ConsoleFmtConfig = FmtConfig#{template => console_template()}, ConsoleFmtConfig = FmtConfig#{template => console_template()},
logger:set_primary_config(level, Level), try
logger:add_primary_filter(progress_report, ok = logger:set_primary_config(level, Level),
{fun ?MODULE:progress_filter/2, stop}), ok = logger:update_formatter_config(default, ConsoleFmtConfig),
logger:update_formatter_config(default, ConsoleFmtConfig), case logger:add_primary_filter(progress_report,
logger:add_handler(ejabberd_log, logger_std_h, {fun ?MODULE:progress_filter/2, stop}) of
#{level => all, ok -> ok;
config => Config#{file => EjabberdLog}, {error, {already_exist, _}} -> ok
formatter => {logger_formatter, FileFmtConfig}}), end,
logger:add_handler(error_log, logger_std_h, case logger:add_handler(ejabberd_log, logger_std_h,
#{level => error, #{level => all,
config => Config#{file => ErrorLog}, config => Config#{file => EjabberdLog},
formatter => {logger_formatter, FileFmtConfig}}), formatter => {logger_formatter, FileFmtConfig}}) of
ok. ok -> ok;
{error, {already_exist, _}} -> ok
end,
case logger:add_handler(error_log, logger_std_h,
#{level => error,
config => Config#{file => ErrorLog},
formatter => {logger_formatter, FileFmtConfig}}) of
ok -> ok;
{error, {already_exist, _}} -> ok
end
catch _:{Tag, Err} when Tag == badmatch; Tag == case_clause ->
?LOG_CRITICAL("Failed to set logging: ~p", [Err]),
Err
end.
restart() -> restart() ->
ok. ok.