25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Add log_modules_fully option to make some modules log everything independed from global loglevel

This commit is contained in:
Paweł Chmielowski 2022-12-01 13:24:46 +01:00
parent 54592202ef
commit d49b50a055
4 changed files with 17 additions and 1 deletions

View File

@ -532,6 +532,7 @@ validate(Y1) ->
case pre_validate(Y1) of case pre_validate(Y1) of
{ok, Y2} -> {ok, Y2} ->
set_loglevel(proplists:get_value(loglevel, Y2, info)), set_loglevel(proplists:get_value(loglevel, Y2, info)),
ejabberd_logger:set_modules_fully_logged(proplists:get_value(log_modules_fully, Y2, [])),
case ejabberd_config_transformer:map_reduce(Y2) of case ejabberd_config_transformer:map_reduce(Y2) of
{ok, Y3} -> {ok, Y3} ->
Hosts = proplists:get_value(hosts, Y3), Hosts = proplists:get_value(hosts, Y3),

View File

@ -27,7 +27,7 @@
%% API %% API
-export([start/0, get/0, set/1, get_log_path/0, flush/0]). -export([start/0, get/0, set/1, get_log_path/0, flush/0]).
-export([convert_loglevel/1, loglevels/0]). -export([convert_loglevel/1, loglevels/0, set_modules_fully_logged/1]).
-ifndef(LAGER). -ifndef(LAGER).
-export([progress_filter/2]). -export([progress_filter/2]).
-endif. -endif.
@ -249,6 +249,8 @@ get_lager_version() ->
false -> "0.0.0" false -> "0.0.0"
end. end.
set_modules_fully_logged(_) -> ok.
flush() -> flush() ->
application:stop(lager), application:stop(lager),
application:stop(sasl). application:stop(sasl).
@ -378,6 +380,10 @@ set(Level) when ?is_loglevel(Level) ->
end end
end. end.
set_modules_fully_logged(Modules) ->
logger:unset_module_level(),
logger:set_module_level(Modules, all).
-spec flush() -> ok. -spec flush() -> ok.
flush() -> flush() ->
lists:foreach( lists:foreach(

View File

@ -74,6 +74,7 @@
-export([listen/0]). -export([listen/0]).
-export([log_burst_limit_count/0]). -export([log_burst_limit_count/0]).
-export([log_burst_limit_window_time/0]). -export([log_burst_limit_window_time/0]).
-export([log_modules_fully/0]).
-export([log_rotate_count/0]). -export([log_rotate_count/0]).
-export([log_rotate_size/0]). -export([log_rotate_size/0]).
-export([loglevel/0]). -export([loglevel/0]).
@ -593,6 +594,10 @@ log_burst_limit_count() ->
log_burst_limit_window_time() -> log_burst_limit_window_time() ->
ejabberd_config:get_option({log_burst_limit_window_time, global}). ejabberd_config:get_option({log_burst_limit_window_time, global}).
-spec log_modules_fully() -> [atom()].
log_modules_fully() ->
ejabberd_config:get_option({log_modules_fully, global}).
-spec log_rotate_count() -> non_neg_integer(). -spec log_rotate_count() -> non_neg_integer().
log_rotate_count() -> log_rotate_count() ->
ejabberd_config:get_option({log_rotate_count, global}). ejabberd_config:get_option({log_rotate_count, global}).

View File

@ -233,6 +233,8 @@ opt_type(log_burst_limit_window_time) ->
econf:timeout(second); econf:timeout(second);
opt_type(log_burst_limit_count) -> opt_type(log_burst_limit_count) ->
econf:pos_int(); econf:pos_int();
opt_type(log_modules_fully) ->
econf:list(econf:atom());
opt_type(loglevel) -> opt_type(loglevel) ->
fun(N) when is_integer(N) -> fun(N) when is_integer(N) ->
(econf:and_then( (econf:and_then(
@ -589,6 +591,7 @@ options() ->
{log_rotate_size, 10*1024*1024}, {log_rotate_size, 10*1024*1024},
{log_burst_limit_window_time, timer:seconds(1)}, {log_burst_limit_window_time, timer:seconds(1)},
{log_burst_limit_count, 500}, {log_burst_limit_count, 500},
{log_modules_fully, []},
{max_fsm_queue, undefined}, {max_fsm_queue, undefined},
{modules, []}, {modules, []},
{negotiation_timeout, timer:seconds(30)}, {negotiation_timeout, timer:seconds(30)},
@ -737,6 +740,7 @@ globals() ->
log_rotate_size, log_rotate_size,
log_burst_limit_count, log_burst_limit_count,
log_burst_limit_window_time, log_burst_limit_window_time,
log_modules_fully,
negotiation_timeout, negotiation_timeout,
net_ticktime, net_ticktime,
new_sql_schema, new_sql_schema,