|
@@ -25,22 +25,19 @@ log(Meta0) ->
|
|
|
Duration = erlang:convert_time_unit(ReqEnd - ReqStart, native, millisecond),
|
|
Duration = erlang:convert_time_unit(ReqEnd - ReqStart, native, millisecond),
|
|
|
Level = level(Method, Code, Duration),
|
|
Level = level(Method, Code, Duration),
|
|
|
Username = maps:get(username, Meta0, <<"">>),
|
|
Username = maps:get(username, Meta0, <<"">>),
|
|
|
|
|
+ From = from(maps:get(auth_type, Meta0, "")),
|
|
|
Meta1 = maps:without([req_start, req_end], Meta0),
|
|
Meta1 = maps:without([req_start, req_end], Meta0),
|
|
|
Meta2 = Meta1#{time => logger:timestamp(), duration_ms => Duration},
|
|
Meta2 = Meta1#{time => logger:timestamp(), duration_ms => Duration},
|
|
|
Meta = emqx_utils:redact(Meta2),
|
|
Meta = emqx_utils:redact(Meta2),
|
|
|
?AUDIT(
|
|
?AUDIT(
|
|
|
Level,
|
|
Level,
|
|
|
- rest_api,
|
|
|
|
|
- Meta#{
|
|
|
|
|
- from => from(maps:get(auth_type, Meta0, "")),
|
|
|
|
|
- username => binary_to_list(Username),
|
|
|
|
|
- node => node()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ From,
|
|
|
|
|
+ Meta#{username => binary_to_list(Username), node => node()}
|
|
|
),
|
|
),
|
|
|
ok.
|
|
ok.
|
|
|
|
|
|
|
|
from(jwt_token) -> "dashboard";
|
|
from(jwt_token) -> "dashboard";
|
|
|
-from(api_key) -> "aip_key";
|
|
|
|
|
|
|
+from(api_key) -> "rest_api";
|
|
|
from(_) -> "unauthorized".
|
|
from(_) -> "unauthorized".
|
|
|
|
|
|
|
|
level(get, _Code, _) -> debug;
|
|
level(get, _Code, _) -> debug;
|