Skip to content

Commit a0b9e65

Browse files
committed
Support logging signals that are encoded as iolists().
These are generated by jiffy in some cases when encoding JSON data.
1 parent e2faff7 commit a0b9e65

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

backend/apps/automate_logging/src/automate_logging.erl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,15 @@ log_signal_to_bridge_and_owner(Signal, BridgeId, {OwnerType, OwnerId}) ->
7171
} ->
7272
Url = lists:flatten(io_lib:format("~s/~s_~p_~s", [BaseURL, BridgeId, OwnerType, OwnerId])),
7373
Type = "application/json",
74-
Body = jiffy:encode(Signal),
74+
Body = list_to_binary([jiffy:encode(Signal)]),
7575
Headers = [],
7676
HTTPOptions = [],
7777
Options = [],
78-
{ok, _} = httpc:request(post, {Url, Headers, Type, Body}, HTTPOptions, Options);
78+
case httpc:request(post, {Url, Headers, Type, Body}, HTTPOptions, Options) of
79+
{ok, _} -> ok;
80+
{error, Reason} ->
81+
log_platform(error, list_to_binary(io_lib:format("Error logging signal: ~p", [Reason])))
82+
end;
7983
undefined ->
8084
io:fwrite("[Error] Signal logging configuration not set")
8185
end.

0 commit comments

Comments
 (0)