fix: dialyzer warning
This commit is contained in:
parent
22223dc536
commit
0634ff61c0
|
@ -63,6 +63,10 @@
|
|||
)
|
||||
end).
|
||||
|
||||
-ifdef(EMQX_RELEASE_EDITION).
|
||||
|
||||
-if(?EMQX_RELEASE_EDITION == ee).
|
||||
|
||||
-define(AUDIT(_LevelFun_, _MetaFun_), begin
|
||||
case logger_config:get(logger, ?AUDIT_HANDLER) of
|
||||
{error, {not_found, _}} ->
|
||||
|
@ -78,6 +82,16 @@ end).
|
|||
end
|
||||
end).
|
||||
|
||||
-else.
|
||||
%% Only for compile pass, ce edition will not call it
|
||||
-define(AUDIT(_L_, _M_), _ = {_L_, _M_}).
|
||||
-endif.
|
||||
|
||||
-else.
|
||||
%% Only for compile pass, ce edition will not call it
|
||||
-define(AUDIT(_L_, _M_), _ = {_L_, _M_}).
|
||||
-endif.
|
||||
|
||||
%% print to 'user' group leader
|
||||
-define(ULOG(Fmt, Args), io:format(user, Fmt, Args)).
|
||||
-define(ELOG(Fmt, Args), io:format(standard_error, Fmt, Args)).
|
||||
|
|
|
@ -108,10 +108,12 @@ log(Level, Meta1, Handler) ->
|
|||
|
||||
remove_handler_when_disabled() ->
|
||||
case emqx_config:get([log, audit, enable], false) of
|
||||
true -> ok;
|
||||
false -> _ = logger:remove_handler(?AUDIT_HANDLER)
|
||||
end,
|
||||
ok.
|
||||
true ->
|
||||
ok;
|
||||
false ->
|
||||
_ = logger:remove_handler(?AUDIT_HANDLER),
|
||||
ok
|
||||
end.
|
||||
|
||||
log_to_db(Log) ->
|
||||
Audit0 = to_audit(Log),
|
||||
|
|
|
@ -21,14 +21,12 @@
|
|||
|
||||
all() ->
|
||||
[
|
||||
{group, enabled},
|
||||
{group, disabled}
|
||||
{group, audit, [sequence]}
|
||||
].
|
||||
|
||||
groups() ->
|
||||
[
|
||||
{enabled, [sequence], common_tests() -- [t_disabled]},
|
||||
{disabled, [sequence], [t_disabled]}
|
||||
{audit, [sequence], common_tests()}
|
||||
].
|
||||
|
||||
common_tests() ->
|
||||
|
@ -114,6 +112,8 @@ t_disabled(_) ->
|
|||
Logs1 = emqx_utils_maps:deep_put([<<"audit">>, <<"max_filter_size">>], Logs, 100),
|
||||
NewLogs = emqx_utils_maps:deep_put([<<"audit">>, <<"enable">>], Logs1, false),
|
||||
{ok, _} = emqx_mgmt_api_configs_SUITE:update_config("log", NewLogs),
|
||||
{ok, GetLog1} = emqx_mgmt_api_configs_SUITE:get_config("log"),
|
||||
?assertEqual(NewLogs, GetLog1),
|
||||
?assertMatch(
|
||||
{error, _},
|
||||
emqx_mgmt_api_test_util:request_api(get, AuditPath, "limit=1", AuthHeader)
|
||||
|
@ -132,6 +132,8 @@ t_disabled(_) ->
|
|||
?assertEqual(Size2, Size3),
|
||||
%% enabled again
|
||||
{ok, _} = emqx_mgmt_api_configs_SUITE:update_config("log", Logs1),
|
||||
{ok, GetLog2} = emqx_mgmt_api_configs_SUITE:get_config("log"),
|
||||
?assertEqual(Logs1, GetLog2),
|
||||
Size4 = mnesia:table_info(emqx_audit, size),
|
||||
?assertEqual(Size3 + 1, Size4),
|
||||
ok.
|
||||
|
@ -243,4 +245,4 @@ kickout_clients() ->
|
|||
|
||||
{ok, Clients2} = emqx_mgmt_api_test_util:request_api(get, ClientsPath),
|
||||
ClientsResponse2 = emqx_utils_json:decode(Clients2, [return_maps]),
|
||||
?assertMatch(#{<<"meta">> := #{<<"count">> := 0}}, ClientsResponse2).
|
||||
?assertMatch(#{<<"data">> := []}, ClientsResponse2).
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
-define(AUDIT_MOD, audit).
|
||||
-define(UPDATE_READONLY_KEYS_PROHIBITED, "update_readonly_keys_prohibited").
|
||||
|
||||
-dialyzer({no_match, [load/0]}).
|
||||
|
||||
load() ->
|
||||
emqx_ctl:register_command(?CLUSTER_CALL, {?MODULE, admins}, [hidden]),
|
||||
emqx_ctl:register_command(?CONF, {?MODULE, conf}, []),
|
||||
|
|
|
@ -210,6 +210,8 @@ filter_false(K, V, S) -> [{K, V} | S].
|
|||
listener_name(Protocol) ->
|
||||
list_to_atom(atom_to_list(Protocol) ++ ":dashboard").
|
||||
|
||||
-dialyzer({no_match, [audit_log_fun/0]}).
|
||||
|
||||
audit_log_fun() ->
|
||||
case emqx_release:edition() of
|
||||
ee -> fun emqx_dashboard_audit:log/2;
|
||||
|
|
|
@ -727,8 +727,7 @@ audit_handler_level.label:
|
|||
|
||||
audit_log_max_filter_limit.desc:
|
||||
"""Store the latest N log entries in a database for allow `/audit` HTTP API to filter and retrieval of log data.
|
||||
The interval for purging redundant log records is maintained within a range of 10~20 seconds.
|
||||
"""
|
||||
The interval for purging redundant log records is maintained within a range of 10~20 seconds."""
|
||||
|
||||
audit_log_max_filter_limit.label:
|
||||
"""Max Filter Limit"""
|
||||
|
|
Loading…
Reference in New Issue