From c69884fa3f52f67596b459ea7d9aad711a7c4165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Wed, 28 Feb 2024 12:03:42 +0100 Subject: [PATCH] Config reload should update loger settings part 2 --- src/ejabberd_config.erl | 3 +++ src/ejabberd_logger.erl | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index 376a458e0..bd9480513 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -111,6 +111,9 @@ reload() -> ejabberd_hooks:run(host_down, [Host]) end, DelHosts), ejabberd_hooks:run(config_reloaded, []), + % logger is started too early to be able to use hooks, so + % we need to call it separately + ejabberd_logger:config_reloaded(), delete_host_options(DelHosts), ?INFO_MSG("Configuration reloaded successfully", []); Err -> diff --git a/src/ejabberd_logger.erl b/src/ejabberd_logger.erl index 38818e354..e57fd8146 100644 --- a/src/ejabberd_logger.erl +++ b/src/ejabberd_logger.erl @@ -27,9 +27,9 @@ %% API -export([start/0, get/0, set/1, get_log_path/0, flush/0]). --export([convert_loglevel/1, loglevels/0, set_modules_fully_logged/1]). +-export([convert_loglevel/1, loglevels/0, set_modules_fully_logged/1, config_reloaded/0]). -ifndef(LAGER). --export([progress_filter/2, config_reloaded/0]). +-export([progress_filter/2]). -endif. %% Deprecated functions -export([restart/0, reopen_log/0, rotate_log/0]). @@ -185,6 +185,9 @@ restart() -> application:stop(lager), start(Level). +config_reloaded() -> + ok. + reopen_log() -> ok. @@ -266,7 +269,6 @@ start(Level) -> EjabberdLog = get_log_path(), Dir = filename:dirname(EjabberdLog), ErrorLog = filename:join([Dir, "error.log"]), - ejabberd_hooks:add(config_reloaded, ?MODULE, config_reloaded, 50), LogRotateSize = get_integer_env(log_rotate_size, 10*1024*1024), LogRotateCount = get_integer_env(log_rotate_count, 1), LogBurstLimitWindowTime = get_integer_env(log_burst_limit_window_time, 1000),