mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Add set_loglevel command (EJABS-2524)
This commit is contained in:
parent
497cbb3ec2
commit
df3862cf84
@ -29,6 +29,7 @@
|
||||
-export([start/0, stop/0,
|
||||
%% Server
|
||||
status/0, reopen_log/0,
|
||||
set_loglevel/1,
|
||||
stop_kindly/2, send_service_message_all_mucs/2,
|
||||
registered_vhosts/0,
|
||||
reload_config/0,
|
||||
@ -102,6 +103,11 @@ commands() ->
|
||||
{levelatom, atom},
|
||||
{leveldesc, string}
|
||||
]}}},
|
||||
#ejabberd_commands{name = set_loglevel, tags = [logs, server],
|
||||
desc = "Set the loglevel (0 to 5)",
|
||||
module = ?MODULE, function = set_loglevel,
|
||||
args = [{loglevel, integer}],
|
||||
result = {logger, atom}},
|
||||
|
||||
#ejabberd_commands{name = update_list, tags = [server],
|
||||
desc = "List modified modules that can be updated",
|
||||
@ -252,6 +258,12 @@ reopen_log() ->
|
||||
ejabberd_hooks:run(reopen_log_hook, []),
|
||||
ejabberd_logger:reopen_log().
|
||||
|
||||
|
||||
set_loglevel(LogLevel) ->
|
||||
{module, Module} = ejabberd_logger:set(LogLevel),
|
||||
Module.
|
||||
|
||||
|
||||
%%%
|
||||
%%% Stop Kindly
|
||||
%%%
|
||||
|
@ -157,7 +157,8 @@ set(LogLevel) when is_integer(LogLevel) ->
|
||||
2 -> error;
|
||||
3 -> warning;
|
||||
4 -> info;
|
||||
5 -> debug
|
||||
5 -> debug;
|
||||
E -> throw({wrong_loglevel, E})
|
||||
end,
|
||||
case lager:get_loglevel(lager_console_backend) of
|
||||
LagerLogLevel ->
|
||||
@ -194,8 +195,10 @@ reopen_log() ->
|
||||
get() ->
|
||||
p1_loglevel:get().
|
||||
|
||||
set(LogLevel) when LogLevel >=0, LogLevel =< 5 ->
|
||||
p1_loglevel:set(LogLevel);
|
||||
set(LogLevel) ->
|
||||
p1_loglevel:set(LogLevel).
|
||||
throw({wrong_loglevel, LogLevel}).
|
||||
|
||||
%%%===================================================================
|
||||
%%% Internal functions
|
||||
|
Loading…
Reference in New Issue
Block a user