fix(config): infinity is not valid for log.max_depth

This commit is contained in:
Zaiming Shi 2021-08-11 09:54:10 +02:00
parent 632cc895d5
commit ac1763cd80
2 changed files with 13 additions and 19 deletions

View File

@ -426,16 +426,16 @@ log {
## Limits the total number of characters printed for each log event.
##
## @doc log.chars_limit
## ValueType: Integer | infinity
## Range: [0, infinity)
## Default: infinity
chars_limit: infinity
## ValueType: unlimited | Integer
## Range: [0, +Inf)
## Default: unlimited
chars_limit: unlimited
## Maximum depth for Erlang term log formatting
## and Erlang process message queue inspection.
##
## @doc log.max_depth
## ValueType: Integer | infinity
## ValueType: unlimited | Integer
## Default: 80
max_depth: 80

View File

@ -161,9 +161,11 @@ fields("log") ->
, {"console_handler", ref("console_handler")}
, {"file_handlers", ref("file_handlers")}
, {"time_offset", t(string(), undefined, "system")}
, {"chars_limit", maybe_infinity(range(1, inf))}
, {"chars_limit", #{type => hoconsc:union([unlimited, range(1, inf)]),
default => unlimited
}}
, {"supervisor_reports", t(union([error, progress]), undefined, error)}
, {"max_depth", t(union([infinity, integer()]),
, {"max_depth", t(union([unlimited, integer()]),
"kernel.error_logger_format_depth", 80)}
, {"formatter", t(union([text, json]), undefined, text)}
, {"single_line", t(boolean(), undefined, true)}
@ -188,7 +190,8 @@ fields("log_file_handler") ->
[ {"level", t(log_level(), undefined, warning)}
, {"file", t(file(), undefined, undefined)}
, {"rotation", ref("log_rotation")}
, {"max_size", maybe_infinity(emqx_schema:bytesize(), "10MB")}
, {"max_size", #{type => union([infinity, emqx_schema:bytesize()]),
default => "10MB"}}
];
fields("log_rotation") ->
@ -258,8 +261,8 @@ tr_logger_level(Conf) -> conf_get("log.primary_level", Conf).
tr_logger(Conf) ->
CharsLimit = case conf_get("log.chars_limit", Conf) of
infinity -> unlimited;
V -> V
unlimited -> unlimited;
V when V > 0 -> V
end,
SingleLine = conf_get("log.single_line", Conf),
FmtName = conf_get("log.formatter", Conf),
@ -378,15 +381,6 @@ t(Type, Mapping, Default, OverrideEnv) ->
ref(Field) -> hoconsc:t(hoconsc:ref(Field)).
maybe_infinity(T) ->
maybe_sth(infinity, T, infinity).
maybe_infinity(T, Default) ->
maybe_sth(infinity, T, Default).
maybe_sth(What, Type, Default) ->
t(union([What, Type]), undefined, Default).
options(static, Conf) ->
[{seeds, [to_atom(S) || S <- conf_get("cluster.static.seeds", Conf, [])]}];
options(mcast, Conf) ->