From a94a199016a26f0b311b3425387363f2a39e4299 Mon Sep 17 00:00:00 2001 From: Tilman Holschuh Date: Fri, 16 Feb 2018 16:45:34 -0800 Subject: [PATCH] Ensure logplex-1 content-type for channel logs endpoint --- src/logplex_api_v3_channel_logs.erl | 5 ++++- test/logplex_api_v3_SUITE.erl | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/logplex_api_v3_channel_logs.erl b/src/logplex_api_v3_channel_logs.erl index 2019d552..006662ba 100644 --- a/src/logplex_api_v3_channel_logs.erl +++ b/src/logplex_api_v3_channel_logs.erl @@ -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]). diff --git a/test/logplex_api_v3_SUITE.erl b/test/logplex_api_v3_SUITE.erl index 3e680913..10b8cc9f 100644 --- a/test/logplex_api_v3_SUITE.erl +++ b/test/logplex_api_v3_SUITE.erl @@ -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.