mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Report errors in logger initialization
This commit is contained in:
parent
86bb77bfc2
commit
1e30b85861
@ -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
|
||||||
|
ok -> ok;
|
||||||
|
{error, {already_exist, _}} -> ok
|
||||||
|
end,
|
||||||
|
case logger:add_handler(ejabberd_log, logger_std_h,
|
||||||
#{level => all,
|
#{level => all,
|
||||||
config => Config#{file => EjabberdLog},
|
config => Config#{file => EjabberdLog},
|
||||||
formatter => {logger_formatter, FileFmtConfig}}),
|
formatter => {logger_formatter, FileFmtConfig}}) of
|
||||||
logger:add_handler(error_log, logger_std_h,
|
ok -> ok;
|
||||||
|
{error, {already_exist, _}} -> ok
|
||||||
|
end,
|
||||||
|
case logger:add_handler(error_log, logger_std_h,
|
||||||
#{level => error,
|
#{level => error,
|
||||||
config => Config#{file => ErrorLog},
|
config => Config#{file => ErrorLog},
|
||||||
formatter => {logger_formatter, FileFmtConfig}}),
|
formatter => {logger_formatter, FileFmtConfig}}) of
|
||||||
ok.
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user