chore: format error log
This commit is contained in:
parent
a84b6b74bd
commit
391eb55324
|
@ -267,13 +267,13 @@ on_action_data_to_webserver(Selected, _Envs =
|
||||||
{ok, StatusCode, _, _} when StatusCode >= 200 andalso StatusCode < 300 ->
|
{ok, StatusCode, _, _} when StatusCode >= 200 andalso StatusCode < 300 ->
|
||||||
emqx_rule_metrics:inc_actions_success(Id);
|
emqx_rule_metrics:inc_actions_success(Id);
|
||||||
{ok, StatusCode, _} ->
|
{ok, StatusCode, _} ->
|
||||||
?LOG(warning, "[WebHook Action] HTTP request failed with status code: ~p", [StatusCode]),
|
?LOG(warning, "HTTP request failed with path: ~p status code: ~p", [NPath, StatusCode]),
|
||||||
emqx_rule_metrics:inc_actions_error(Id);
|
emqx_rule_metrics:inc_actions_error(Id);
|
||||||
{ok, StatusCode, _, _} ->
|
{ok, StatusCode, _, _} ->
|
||||||
?LOG(warning, "[WebHook Action] HTTP request failed with status code: ~p", [StatusCode]),
|
?LOG(warning, "HTTP request failed with path: ~p status code: ~p", [NPath, StatusCode]),
|
||||||
emqx_rule_metrics:inc_actions_error(Id);
|
emqx_rule_metrics:inc_actions_error(Id);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?LOG(error, "[WebHook Action] HTTP request error: ~p", [Reason]),
|
?LOG(error, "HTTP request failed path: ~p error: ~p", [NPath, Reason]),
|
||||||
emqx_rule_metrics:inc_actions_error(Id)
|
emqx_rule_metrics:inc_actions_error(Id)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -293,20 +293,16 @@ create_req(_, Path, Headers, Body) ->
|
||||||
{Path, Headers, Body}.
|
{Path, Headers, Body}.
|
||||||
|
|
||||||
parse_action_params(Params = #{<<"url">> := URL}) ->
|
parse_action_params(Params = #{<<"url">> := URL}) ->
|
||||||
try
|
{ok, #{path := CommonPath}} = emqx_http_lib:uri_parse(URL),
|
||||||
{ok, #{path := CommonPath}} = emqx_http_lib:uri_parse(URL),
|
Method = method(maps:get(<<"method">>, Params, <<"POST">>)),
|
||||||
Method = method(maps:get(<<"method">>, Params, <<"POST">>)),
|
Headers = headers(maps:get(<<"headers">>, Params, undefined)),
|
||||||
Headers = headers(maps:get(<<"headers">>, Params, undefined)),
|
NHeaders = ensure_content_type_header(Headers, Method),
|
||||||
NHeaders = ensure_content_type_header(Headers, Method),
|
#{method => Method,
|
||||||
#{method => Method,
|
path => merge_path(CommonPath, maps:get(<<"path">>, Params, <<>>)),
|
||||||
path => merge_path(CommonPath, maps:get(<<"path">>, Params, <<>>)),
|
headers => NHeaders,
|
||||||
headers => NHeaders,
|
body => maps:get(<<"body">>, Params, <<>>),
|
||||||
body => maps:get(<<"body">>, Params, <<>>),
|
request_timeout => cuttlefish_duration:parse(str(maps:get(<<"request_timeout">>, Params, <<"5s">>))),
|
||||||
request_timeout => cuttlefish_duration:parse(str(maps:get(<<"request_timeout">>, Params, <<"5s">>))),
|
pool => maps:get(<<"pool">>, Params)}.
|
||||||
pool => maps:get(<<"pool">>, Params)}
|
|
||||||
catch _:_ ->
|
|
||||||
throw({invalid_params, Params})
|
|
||||||
end.
|
|
||||||
|
|
||||||
ensure_content_type_header(Headers, Method) when Method =:= post orelse Method =:= put ->
|
ensure_content_type_header(Headers, Method) when Method =:= post orelse Method =:= put ->
|
||||||
Headers;
|
Headers;
|
||||||
|
|
Loading…
Reference in New Issue