From 0407450784f144882eaef8c060d108fbd7dec9bb Mon Sep 17 00:00:00 2001 From: suexcxine Date: Fri, 8 Sep 2017 23:08:56 +0800 Subject: [PATCH] Support unicode format string --- src/lager_format.erl | 2 +- src/lager_trunc_io.erl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lager_format.erl b/src/lager_format.erl index b4eac89..3233554 100644 --- a/src/lager_format.erl +++ b/src/lager_format.erl @@ -36,7 +36,7 @@ format(FmtStr, Args, MaxLen, Opts) when is_atom(FmtStr) -> format(FmtStr, Args, MaxLen, Opts) when is_binary(FmtStr) -> format(binary_to_list(FmtStr), Args, MaxLen, Opts); format(FmtStr, Args, MaxLen, Opts) when is_list(FmtStr) -> - case lager_stdlib:string_p(FmtStr) of + case io_lib:deep_char_list(FmtStr) of true -> Options = make_options(Opts, #options{}), Cs = collect(FmtStr, Args), diff --git a/src/lager_trunc_io.erl b/src/lager_trunc_io.erl index 7ed34c1..64b3d76 100644 --- a/src/lager_trunc_io.erl +++ b/src/lager_trunc_io.erl @@ -874,7 +874,8 @@ depth_limit_test() -> print_terms_without_format_string_test() -> ?assertError(badarg, format({hello, world}, [], 50)), ?assertError(badarg, format([{google, bomb}], [], 50)), - ?assertError(badarg, format([$h,$e,$l,$l,$o, 3594], [], 50)), + ?assertEqual([$h,$e,$l,$l,$o, 3594], format([$h,$e,$l,$l,$o, 3594], [], 50)), + ?assertError(badarg, format([$h,$e,$l,$l,$o, 65535], [], 50)), ?assertEqual("helloworld", lists:flatten(format([$h,$e,$l,$l,$o, "world"], [], 50))), ?assertEqual("hello", lists:flatten(format(<<"hello">>, [], 50))), ?assertEqual("hello", lists:flatten(format('hello', [], 50))),