From d31a44f96b457dc1b597119c26caa7dadc23913f Mon Sep 17 00:00:00 2001 From: Zhongwen Deng Date: Fri, 5 May 2023 09:53:54 +0800 Subject: [PATCH] feat: convert rotation from map to integer --- apps/emqx_conf/src/emqx_conf_schema.erl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/emqx_conf/src/emqx_conf_schema.erl b/apps/emqx_conf/src/emqx_conf_schema.erl index 09f51a3b7..682e8f59d 100644 --- a/apps/emqx_conf/src/emqx_conf_schema.erl +++ b/apps/emqx_conf/src/emqx_conf_schema.erl @@ -909,6 +909,7 @@ fields("log_file_handler") -> #{ aliases => [rotation], default => 10, + converter => fun convert_rotation/2, desc => ?DESC("log_rotation_count"), importance => ?IMPORTANCE_MEDIUM } @@ -1345,3 +1346,7 @@ ensure_file_handlers(Conf, _Opts) -> HandlersWithoutName = maps:with(FileFields, Conf), HandlersWithName = maps:without(FileFields, Conf), emqx_utils_maps:deep_merge(#{<<"default">> => HandlersWithoutName}, HandlersWithName). + +convert_rotation(undefined, _Opts) -> undefined; +convert_rotation(#{} = Rotation, _Opts) -> maps:get(count, Rotation, 10); +convert_rotation(Count, _Opts) when is_integer(Count) -> Count.