Explorar o código

refactor(emqx_conf_schema): use hocon enum type for log levels

Zaiming (Stone) Shi %!s(int64=2) %!d(string=hai) anos
pai
achega
b3df8604fc
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  1. 7 1
      apps/emqx_conf/src/emqx_conf_schema.erl

+ 7 - 1
apps/emqx_conf/src/emqx_conf_schema.erl

@@ -33,6 +33,9 @@
 -export([
     namespace/0, roots/0, fields/1, translations/0, translation/1, validations/0, desc/1, tags/0
 ]).
+
+-export([log_level/0]).
+
 -export([conf_get/2, conf_get/3, keys/2, filter/1]).
 -export([upgrade_raw_conf/1]).
 
@@ -1279,7 +1282,7 @@ log_handler_common_confs(Handler, Default) ->
     [
         {"level",
             sc(
-                hoconsc:enum([debug, info, notice, warning, error, critical, alert, emergency, all]),
+                log_level(),
                 #{
                     default => maps:get(level, Default, warning),
                     desc => ?DESC(LevelDesc),
@@ -1528,3 +1531,6 @@ ensure_unicode_path(Path, _) when is_list(Path) ->
     Path;
 ensure_unicode_path(Path, _) ->
     throw({"not_string", Path}).
+
+log_level() ->
+    hoconsc:enum([debug, info, notice, warning, error, critical, alert, emergency, all]).