add domain

This commit is contained in:
lsxredrain 2021-08-30 12:38:31 +08:00
parent 3e6623ec39
commit e8ce9d0f40
3 changed files with 11 additions and 10 deletions

View File

@ -27,7 +27,7 @@
begin
(logger:log(Level, #{}, #{
report_cb => fun(_) -> {'$logger_header'() ++ (Format), (Args)} end,
domain => [public_dgiot],
domain => [dgiot_public],
mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY},
line => ?LINE}))
end).
@ -45,7 +45,7 @@
begin
(logger:log(Level, #{}, #{
report_cb => fun(_) -> Map end,
domain => [public_dgiot],
domain => [dgiot_public],
mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY},
line => ?LINE}))
end).

View File

@ -200,10 +200,10 @@ send(Meta, Payload) when is_list(Payload) ->
send(#{error_logger := _Error_logger, mfa := {M, F, A}} = _Meta, Payload) ->
Mfa = <<(atom_to_binary(M, utf8))/binary, $/, (atom_to_binary(F, utf8))/binary, $/, (integer_to_binary(A))/binary>>,
Topic = <<"logger_trace/", Mfa/binary>>,
Topic = <<"logger_trace/error/", Mfa/binary>>,
dgiot_mqtt:publish(Mfa, Topic, Payload),
Map = jiffy:decode(Payload, [return_maps]),
NewMap = maps:with([<<"time">>, <<"pid">>, <<"msg">>, <<"mfa">>, <<"line">>, <<"level">>, <<"clientid">>, <<"topic">>, <<"peername">>],Map),
NewMap = maps:with([<<"domain">>,<<"time">>, <<"pid">>, <<"msg">>, <<"mfa">>, <<"line">>, <<"level">>, <<"clientid">>, <<"topic">>, <<"peername">>],Map),
dgiot_parse_cache:save_to_cache(#{<<"method">> => <<"POST">>,
<<"path">> => <<"/classes/Log">>,
<<"body">> => get_body(NewMap)});
@ -232,7 +232,7 @@ send(#{mfa := _MFA} = _Meta, Payload) ->
<<"logger_trace/log/", Mfa/binary, "/", Line/binary>>
end,
dgiot_mqtt:publish(Mfa, Topic, Payload),
NewMap = maps:with([<<"time">>, <<"pid">>, <<"msg">>, <<"mfa">>, <<"line">>, <<"level">>, <<"clientid">>, <<"topic">>, <<"peername">>],Map),
NewMap = maps:with([<<"domain">>,<<"time">>, <<"pid">>, <<"msg">>, <<"mfa">>, <<"line">>, <<"level">>, <<"clientid">>, <<"topic">>, <<"peername">>],Map),
dgiot_parse_cache:save_to_cache(#{
<<"method">> => <<"POST">>,
<<"path">> => <<"/classes/Log">>,

View File

@ -42,9 +42,10 @@
-define(LOG(Level, Format), ?LOG(Level, Format, [])).
-define(LOG(Level, Format, Args),
begin
(logger:log(Level,#{},#{report_cb => fun(_) -> {'$logger_header'()++(Format), (Args)} end,
mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY},
line => ?LINE}))
end).
begin
(logger:log(Level, #{}, #{report_cb => fun(_) -> {'$logger_header'() ++ (Format), (Args)} end,
domain => [emqx_public],
mfa => {?MODULE, ?FUNCTION_NAME, ?FUNCTION_ARITY},
line => ?LINE}))
end).