Change loglevel on configuration reload

This commit is contained in:
Evgeniy Khramtsov 2017-02-27 11:11:29 +03:00
parent d523357ba8
commit 7a9fa52e91
2 changed files with 21 additions and 26 deletions

View File

@ -161,11 +161,6 @@ delete_pid_file() ->
end.
set_settings_from_config() ->
Level = ejabberd_config:get_option(
loglevel,
fun(P) when P>=0, P=<5 -> P end,
4),
ejabberd_logger:set(Level),
Ticktime = ejabberd_config:get_option(
net_ticktime,
opt_type(net_ticktime),
@ -185,16 +180,7 @@ opt_type(net_ticktime) ->
fun (P) when is_integer(P), P > 0 -> P end;
opt_type(cluster_nodes) ->
fun (Ns) -> true = lists:all(fun is_atom/1, Ns), Ns end;
opt_type(loglevel) ->
fun (P) when P >= 0, P =< 5 -> P end;
opt_type(modules) ->
fun (Mods) ->
lists:map(fun ({M, A}) when is_atom(M), is_list(A) ->
{M, A}
end,
Mods)
end;
opt_type(_) -> [cluster_nodes, loglevel, modules, net_ticktime].
opt_type(_) -> [cluster_nodes, net_ticktime].
setup_if_elixir_conf_used() ->
case ejabberd_config:is_using_elixir_config() of

View File

@ -354,7 +354,6 @@ get_absolute_path(File) ->
filename:absname(File)
end.
search_hosts(Term, State) ->
case Term of
{host, Host} ->
@ -772,20 +771,28 @@ set_opts(State) ->
lists:foreach(fun mnesia:write/1, Opts)
end,
case mnesia:transaction(F) of
{atomic, _} -> ok;
{atomic, _} ->
set_log_level();
{aborted,{no_exists,Table}} ->
MnesiaDirectory = mnesia:system_info(directory),
?ERROR_MSG("Error reading Mnesia database spool files:~n"
"The Mnesia database couldn't read the spool file for the table '~p'.~n"
"ejabberd needs read and write access in the directory:~n ~s~n"
"Maybe the problem is a change in the computer hostname,~n"
"or a change in the Erlang node name, which is currently:~n ~p~n"
"Check the ejabberd guide for details about changing the~n"
"computer hostname or Erlang node name.~n",
[Table, MnesiaDirectory, node()]),
?CRITICAL_MSG("Error reading Mnesia database spool files:~n"
"The Mnesia database couldn't read the spool file for the table '~p'.~n"
"ejabberd needs read and write access in the directory:~n ~s~n"
"Maybe the problem is a change in the computer hostname,~n"
"or a change in the Erlang node name, which is currently:~n ~p~n"
"Check the ejabberd guide for details about changing the~n"
"computer hostname or Erlang node name.~n",
[Table, MnesiaDirectory, node()]),
exit("Error reading Mnesia database")
end.
set_log_level() ->
Level = ejabberd_config:get_option(
loglevel,
fun(P) when P>=0, P=<5 -> P end,
4),
ejabberd_logger:set(Level).
add_global_option(Opt, Val) ->
add_option(Opt, Val).
@ -1445,9 +1452,11 @@ opt_type(default_db) ->
fun(T) when is_atom(T) -> T end;
opt_type(default_ram_db) ->
fun(T) when is_atom(T) -> T end;
opt_type(loglevel) ->
fun (P) when P >= 0, P =< 5 -> P end;
opt_type(_) ->
[hide_sensitive_log_data, hosts, language,
default_db, default_ram_db].
default_db, default_ram_db, loglevel].
-spec may_hide_data(any()) -> any().
may_hide_data(Data) ->