Skip to content

Commit

Permalink
feat: new logger
Browse files Browse the repository at this point in the history
  • Loading branch information
blackyyyyyyyyyy committed Jul 20, 2023
1 parent 21c34cf commit f9bd5d3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/minirest.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,19 @@
, handler/0
]).
reply(Code, Header,Body, Req) ->
io:format("Reply ~p ~0p~n ~0p~n ~0p~n", [Code, Header, Body, Req]),
cowboy_req:reply(Code, Header, Body, Req).
Res = cowboy_req:reply(Code, Header, Body, Req),
try persistent_term:get(minirest_logger, undefined) of
undefined ->
% ignore
ok;
{Module, Func} ->
erlang:apply(Module, Func, [Code, Header, Body, Req]);
Fun ->
Fun(Code, Header, Body, Req)
catch _:_ ->
ok
end,
Res.

%%------------------------------------------------------------------------------
%% Start/Stop Http
Expand Down

0 comments on commit f9bd5d3

Please sign in to comment.