25
1
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:
Jerome Sautret 2015-09-21 17:07:44 +02:00
parent 497cbb3ec2
commit df3862cf84
2 changed files with 17 additions and 2 deletions

View File

@ -29,6 +29,7 @@
-export([start/0, stop/0, -export([start/0, stop/0,
%% Server %% Server
status/0, reopen_log/0, status/0, reopen_log/0,
set_loglevel/1,
stop_kindly/2, send_service_message_all_mucs/2, stop_kindly/2, send_service_message_all_mucs/2,
registered_vhosts/0, registered_vhosts/0,
reload_config/0, reload_config/0,
@ -102,6 +103,11 @@ commands() ->
{levelatom, atom}, {levelatom, atom},
{leveldesc, string} {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], #ejabberd_commands{name = update_list, tags = [server],
desc = "List modified modules that can be updated", desc = "List modified modules that can be updated",
@ -252,6 +258,12 @@ reopen_log() ->
ejabberd_hooks:run(reopen_log_hook, []), ejabberd_hooks:run(reopen_log_hook, []),
ejabberd_logger:reopen_log(). ejabberd_logger:reopen_log().
set_loglevel(LogLevel) ->
{module, Module} = ejabberd_logger:set(LogLevel),
Module.
%%% %%%
%%% Stop Kindly %%% Stop Kindly
%%% %%%

View File

@ -157,7 +157,8 @@ set(LogLevel) when is_integer(LogLevel) ->
2 -> error; 2 -> error;
3 -> warning; 3 -> warning;
4 -> info; 4 -> info;
5 -> debug 5 -> debug;
E -> throw({wrong_loglevel, E})
end, end,
case lager:get_loglevel(lager_console_backend) of case lager:get_loglevel(lager_console_backend) of
LagerLogLevel -> LagerLogLevel ->
@ -194,8 +195,10 @@ reopen_log() ->
get() -> get() ->
p1_loglevel:get(). p1_loglevel:get().
set(LogLevel) when LogLevel >=0, LogLevel =< 5 ->
p1_loglevel:set(LogLevel);
set(LogLevel) -> set(LogLevel) ->
p1_loglevel:set(LogLevel). throw({wrong_loglevel, LogLevel}).
%%%=================================================================== %%%===================================================================
%%% Internal functions %%% Internal functions