Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #227 from heroku/ypaq-ensure-logplex-1-content-typ…
Browse files Browse the repository at this point in the history
…e-for-channel-logs

Ensure logplex-1 content-type for channel logs endpoint
  • Loading branch information
cyx authored Feb 17, 2018
2 parents a64b8f8 + a94a199 commit ddafa61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/logplex_api_v3_channel_logs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@ serve_logs(Logs, WriteChunkFun) ->
prepare_logs([], Acc) ->
Acc;
prepare_logs([Msg | Logs], Acc) ->
prepare_logs(Logs, [list_to_binary([Msg, $\n]) | Acc]).
prepare_logs(Logs, [prepare_msg(Msg) | Acc]).

prepare_msg(Msg) ->
logplex_syslog_utils:frame([Msg, $\n]).
6 changes: 5 additions & 1 deletion test/logplex_api_v3_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,11 @@ fetch_channel_logs(Config0) ->
?assertEqual("chunked", proplists:get_value("transfer-encoding", Headers)),
?assertEqual("close", proplists:get_value("connection", Headers)),
Lines = re:split(proplists:get_value(body, Props), "\n", [trim]),
[?assertEqual(match, re:run(Line, Expected, [{capture, none}])) || {{_, Expected}, Line} <- lists:zip(ExpectedLogMsgs, Lines)],
[begin
?assertEqual(match, re:run(Line, Expected, [{capture, none}])),
NBin = list_to_binary(integer_to_list(N)),
?assertMatch(<<"72 <", NBin:1/binary, _/binary>>, Line)
end || {{N, Expected}, Line} <- lists:zip(ExpectedLogMsgs, Lines)],
Config.


Expand Down

0 comments on commit ddafa61

Please sign in to comment.