chore(audit): emit the message field

This commit is contained in:
JianBo He 2023-09-28 11:04:42 +08:00
parent 859b122cdd
commit 6d2adfc259
3 changed files with 7 additions and 6 deletions

View File

@ -61,9 +61,7 @@
) )
end). end).
-define(AUDIT(_Level_, _From_, _Meta_), ?AUDIT(_Level_, _From_, undefined, _Meta_)). -define(AUDIT(_Level_, _From_, _Meta_), begin
-define(AUDIT(_Level_, _From_, _Msg_, _Meta_), begin
case emqx_config:get([log, audit], #{enable => false}) of case emqx_config:get([log, audit], #{enable => false}) of
#{enable := false} -> #{enable := false} ->
ok; ok;
@ -73,7 +71,7 @@ end).
emqx_trace:log( emqx_trace:log(
_Level_, _Level_,
[{emqx_audit, fun(L, _) -> L end, undefined, undefined}], [{emqx_audit, fun(L, _) -> L end, undefined, undefined}],
{report, _Msg_}, _Msg = undefined,
_Meta_#{from => _From_} _Meta_#{from => _From_}
); );
gt -> gt ->

View File

@ -93,6 +93,8 @@ format(Msg, Meta, Config) ->
end, end,
emqx_utils_json:encode(json_obj_root(Data, Config)). emqx_utils_json:encode(json_obj_root(Data, Config)).
maybe_format_msg(undefined, _Meta, _Config) ->
#{};
maybe_format_msg({report, Report} = Msg, #{report_cb := Cb} = Meta, Config) -> maybe_format_msg({report, Report} = Msg, #{report_cb := Cb} = Meta, Config) ->
case is_map(Report) andalso Cb =:= ?DEFAULT_FORMATTER of case is_map(Report) andalso Cb =:= ?DEFAULT_FORMATTER of
true -> true ->

View File

@ -67,8 +67,9 @@ graceful() ->
%% @doc Shutdown the Erlang VM and wait indefinitely. %% @doc Shutdown the Erlang VM and wait indefinitely.
graceful_wait() -> graceful_wait() ->
?AUDIT(alert, cli, run_emqx_stop_to_grace_shutdown, #{ ?AUDIT(alert, cli, #{
time => logger:timestamp() time => logger:timestamp(),
event => emqx_gracefully_stop
}), }),
ok = graceful(), ok = graceful(),
exit_loop(). exit_loop().