Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: basho/lager
...
head fork: basho/lager
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 13 additions and 2 deletions.
  1. +5 −1 src/lager_format.erl
  2. +8 −1 src/lager_trunc_io.erl
View
6 src/lager_format.erl
@@ -243,8 +243,12 @@ control2($s, [L0], F, Adj, P, Pad, unicode, L) ->
Res = uniconv(string(List, F, Adj, P, Pad)),
{Res, lists:flatlength(Res)}.
+maybe_flatten(<<>>) ->
+ [];
+maybe_flatten([]) ->
+ [];
maybe_flatten(X) when is_list(X) ->
- lists:flatten(X);
+ erlang:iolist_to_binary(X);
maybe_flatten(X) ->
X.
View
9 src/lager_trunc_io.erl
@@ -141,7 +141,7 @@ print(Binary, Max, Options) when is_binary(Binary) ->
{L, Len} = case Options#print_options.lists_as_strings orelse
Options#print_options.force_strings of
true ->
- alist_start(B, Max-4, Options);
+ alist_start(B, Max, Options);
_ ->
list_body(B, Max-4, Options, false)
end,
@@ -460,8 +460,11 @@ quote_strip_test() ->
binary_printing_test() ->
?assertEqual("<<>>", lists:flatten(format("~p", [<<>>], 50))),
+ ?assertEqual("", lists:flatten(format("~s", [<<>>], 50))),
+ ?assertEqual(" ", lists:flatten(format("~s", [<<" ">>], 50))),
?assertEqual("<<..>>", lists:flatten(format("~p", [<<"hi">>], 0))),
?assertEqual("<<...>>", lists:flatten(format("~p", [<<"hi">>], 1))),
+ ?assertEqual("hello w...", lists:flatten(format("~s", [<<"hello world">>], 10))),
?assertEqual("<<\"hello\">>", lists:flatten(format("~p", [<<$h, $e, $l, $l, $o>>], 50))),
?assertEqual("<<\"hello\">>", lists:flatten(format("~p", [<<"hello">>], 50))),
?assertEqual("<<104,101,108,108,111>>", lists:flatten(format("~w", [<<"hello">>], 50))),
@@ -473,6 +476,10 @@ binary_printing_test() ->
?assertEqual(" hello", lists:flatten(format("~10s", [<<"hello">>], 50))),
ok.
+iolist_printing_test() ->
+ ?assertEqual("this is an iolist", lists:flatten(format("~s", [["this", 32, $i, $s, 32, [$a, $n], 32, <<"iolist">>]], 50))),
+ ok.
+
bitstring_printing_test() ->
?assertEqual("<<1,2,3,1:7>>", lists:flatten(format("~p",
[<<1, 2, 3, 1:7>>], 100))),

No commit comments for this range

Something went wrong with that request. Please try again.