From d49b50a055f0cd3696348c0ff8e89a9ea7ab5011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Thu, 1 Dec 2022 13:24:46 +0100 Subject: [PATCH] Add log_modules_fully option to make some modules log everything independed from global loglevel --- src/ejabberd_config.erl | 1 + src/ejabberd_logger.erl | 8 +++++++- src/ejabberd_option.erl | 5 +++++ src/ejabberd_options.erl | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index c5d8c4494..bf298df27 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -532,6 +532,7 @@ validate(Y1) -> case pre_validate(Y1) of {ok, Y2} -> 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 {ok, Y3} -> Hosts = proplists:get_value(hosts, Y3), diff --git a/src/ejabberd_logger.erl b/src/ejabberd_logger.erl index 3d6c08650..bcd9dc71a 100644 --- a/src/ejabberd_logger.erl +++ b/src/ejabberd_logger.erl @@ -27,7 +27,7 @@ %% API -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). -export([progress_filter/2]). -endif. @@ -249,6 +249,8 @@ get_lager_version() -> false -> "0.0.0" end. +set_modules_fully_logged(_) -> ok. + flush() -> application:stop(lager), application:stop(sasl). @@ -378,6 +380,10 @@ set(Level) when ?is_loglevel(Level) -> end end. +set_modules_fully_logged(Modules) -> + logger:unset_module_level(), + logger:set_module_level(Modules, all). + -spec flush() -> ok. flush() -> lists:foreach( diff --git a/src/ejabberd_option.erl b/src/ejabberd_option.erl index 588721895..4ac2e88a4 100644 --- a/src/ejabberd_option.erl +++ b/src/ejabberd_option.erl @@ -74,6 +74,7 @@ -export([listen/0]). -export([log_burst_limit_count/0]). -export([log_burst_limit_window_time/0]). +-export([log_modules_fully/0]). -export([log_rotate_count/0]). -export([log_rotate_size/0]). -export([loglevel/0]). @@ -593,6 +594,10 @@ log_burst_limit_count() -> log_burst_limit_window_time() -> 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(). log_rotate_count() -> ejabberd_config:get_option({log_rotate_count, global}). diff --git a/src/ejabberd_options.erl b/src/ejabberd_options.erl index 1eff76575..345dd3890 100644 --- a/src/ejabberd_options.erl +++ b/src/ejabberd_options.erl @@ -233,6 +233,8 @@ opt_type(log_burst_limit_window_time) -> econf:timeout(second); opt_type(log_burst_limit_count) -> econf:pos_int(); +opt_type(log_modules_fully) -> + econf:list(econf:atom()); opt_type(loglevel) -> fun(N) when is_integer(N) -> (econf:and_then( @@ -589,6 +591,7 @@ options() -> {log_rotate_size, 10*1024*1024}, {log_burst_limit_window_time, timer:seconds(1)}, {log_burst_limit_count, 500}, + {log_modules_fully, []}, {max_fsm_queue, undefined}, {modules, []}, {negotiation_timeout, timer:seconds(30)}, @@ -737,6 +740,7 @@ globals() -> log_rotate_size, log_burst_limit_count, log_burst_limit_window_time, + log_modules_fully, negotiation_timeout, net_ticktime, new_sql_schema,