From 5ed560b5957506320c68e9c14f2c2421acb96ffe Mon Sep 17 00:00:00 2001 From: andrei zavada Date: Fri, 31 Jul 2026 00:54:29 +0100 Subject: [PATCH] accept 'infinity' for MaxNumBytes which is a valid value for max_no_bytes in logger_disk_log_h config --- include/riak_logger_config.hrl | 4 ++-- src/riak_logger.app.src | 2 +- src/riak_logger_config.erl | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/riak_logger_config.hrl b/include/riak_logger_config.hrl index 2c167b5..3695d7f 100644 --- a/include/riak_logger_config.hrl +++ b/include/riak_logger_config.hrl @@ -19,7 +19,7 @@ -type config_map() :: any(). -type config_fetch_fun() :: - fun((string(), config_map()) -> list()|pos_integer()). + fun((string(), config_map()) -> list() | infinity | pos_integer()). -type standard_handler() :: {handler, atom(), logger_std_h, map()}. @@ -36,4 +36,4 @@ -define(DEFAULT_FILTERS_CFGKEY, "logger.default_filters"). -define(ADDITIONAL_HANDLERS_CFGKEY, "logger.additional_handlers"). --define(STANDARD_FILTERS, [crash, error, progress, report, sasl]). \ No newline at end of file +-define(STANDARD_FILTERS, [crash, error, progress, report, sasl]). diff --git a/src/riak_logger.app.src b/src/riak_logger.app.src index a16e13a..ad78abd 100644 --- a/src/riak_logger.app.src +++ b/src/riak_logger.app.src @@ -21,7 +21,7 @@ {application, riak_logger, [ {description, "Riak Kernel Logger Support"}, - {vsn, "1.2.2"}, + {vsn, "1.2.3"}, {registered, []}, {applications, [kernel, stdlib]}, {env, []}, diff --git a/src/riak_logger_config.erl b/src/riak_logger_config.erl index 90f093b..25bc1fc 100644 --- a/src/riak_logger_config.erl +++ b/src/riak_logger_config.erl @@ -108,6 +108,12 @@ conf_getint(Key, ConfFetchFun, Conf) -> I when erlang:is_integer(I) -> I end. +conf_getint_or_infinity(Key, ConfFetchFun, Conf) -> + case ConfFetchFun(Key, Conf) of + infinity -> infinity; + I when erlang:is_integer(I) -> + I + end. -spec conf_getlist(string(), config_fetch_fun(), config_map()) -> list(). conf_getlist(Key, ConfFetchFun, Conf) -> @@ -131,7 +137,7 @@ conf_getatomlist(Key, ConfFetchFun, Conf) -> list(term()), list(tuple()), list(atom()), - pos_integer(), + infinity | pos_integer(), pos_integer() } } | {error, term()}. @@ -167,15 +173,15 @@ parse_inputs(ConfFetchFun, Conf) -> end, case { DefaultFilter, - conf_getint(?MAX_FILESIZE_CFGKEY, ConfFetchFun, Conf), + conf_getint_or_infinity(?MAX_FILESIZE_CFGKEY, ConfFetchFun, Conf), conf_getint(?MAX_FILECOUNT_CFGKEY, ConfFetchFun, Conf) } of {{error, Term}, _, _} -> {error, Term}; {Filter, MaxNumBytes, MaxNumFiles} when - erlang:is_integer(MaxNumBytes), MaxNumBytes > 0, - erlang:is_integer(MaxNumFiles), MaxNumFiles > 0 -> + ((erlang:is_integer(MaxNumBytes) andalso MaxNumBytes > 0) orelse (MaxNumBytes == infinity)) + andalso erlang:is_integer(MaxNumFiles) andalso MaxNumFiles > 0 -> { ok, { @@ -253,7 +259,7 @@ get_handler(json, ConfFun, Conf, MaxNumBytes, MaxNumFiles, _FormatTerm) -> ). -spec standard_config( - string(), pos_integer(), pos_integer()) -> #{atom() => any()}. + string(), infinity | pos_integer(), pos_integer()) -> #{atom() => any()}. standard_config(File, MaxNumBytes, MaxNumFiles) -> #{ file => File, @@ -780,4 +786,4 @@ domain_config_test() -> ?assertMatch(ExpectedHandlers, DomainConfig). --endif. \ No newline at end of file +-endif.