diff options
| author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2020-02-10 11:06:20 +0100 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2020-02-10 11:06:20 +0100 |
| commit | 15dfe7b1bf63c6f6b9940738b219f08bcc241cbd (patch) | |
| tree | f9e0749afbaabc126923f02814002525cc164b7f | |
| parent | 169eeeb426b1c71e5b4e81f8fa813cab9570247a (diff) | |
| download | rabbitmq-server-git-15dfe7b1bf63c6f6b9940738b219f08bcc241cbd.tar.gz | |
rabbit_lager: Fix log level being set from the configuration file
After changing the module to take into account the log level set from
the `$RABBITMQ_LOG` environment variable, I broke the ability to set it
from the configuration file.
This should work again.
| -rw-r--r-- | src/rabbit_lager.erl | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/rabbit_lager.erl b/src/rabbit_lager.erl index 1ec47da12b..547dd9be7e 100644 --- a/src/rabbit_lager.erl +++ b/src/rabbit_lager.erl @@ -561,7 +561,33 @@ generate_lager_sinks(SinkNames, SinkConfigs) -> #{global := LogLevel} -> LogLevel; _ -> - default_config_value(level) + LogConfig = application:get_env(rabbit, log, []), + FoundLL = + lists:foldl( + fun + ({_, Cfg}, LL) when is_list(Cfg) -> + NewLL = proplists:get_value( + level, Cfg, LL), + case LL of + undefined -> + NewLL; + _ -> + MoreVerbose = + lager_util:level_to_num(NewLL) + > + lager_util:level_to_num(LL), + case MoreVerbose of + true -> NewLL; + false -> LL + end + end; + (_, LL) -> + LL + end, undefined, LogConfig), + case FoundLL of + undefined -> default_config_value(level); + _ -> FoundLL + end end, lists:map(fun(SinkName) -> SinkConfig = proplists:get_value(SinkName, SinkConfigs, []), |
