lager
lager copied to clipboard
donot support "~tp" unicode encode
R16B2 support ~tp
format term with utf8 binary as unicode:
erl +pc unicode
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V7.0 (abort with ^G)
1> io_lib:format("~tp", [#{name=><<"测试中文"/utf8>>}]).
[[35,123,
[["name"," => ",[60,60,"\"测试中文\"","/utf8>>"]]],
125]]
but lager treat ~tp
as ~p
lager:safe_format("~tp",[#{name=><<"测试中文"/utf8>>}], 1000).
["#{name => <<230,181,139,232,175,149,228,184,173,230,150,135>>}"]
Hey I'm running into the same issue! Any idea why this is the case?
lager_trunc_io doesn't seem to support the t
modifier to ~p
- that's why it doesn't work.
io_lib:format works because it's part of OTP - lager_trunc_io is a sort-of internal fork that cuts off output, but I think it was before there was a ~tp construction as part of OTP.
Dup of #358
@Vagabond I spent a few hours today looking at this issue, thinking about a newer "modern" replacement for trunc_io. I was pleased to see that https://github.com/erlang/otp/blob/master/lib/stdlib/src/io_lib_pretty.erl supports a maximum number of characters already (this is specifically around supporting "~tp" as a format string) and I'm wondering how safe it would be to just jncorporate that code.
I guess it wouldn't do the special formatting for records and stacktraces, but we could always special case that stuff I suppose.
I am open to exploring this.
So #417 doesn't fix the original problem where the data's encoded as a binary string but, it does work correctly here:
4> lager:log(info, self(), "测试中文").
16:56:11.491 [info] 测试中文
So seems like there's still an issue with binary UTF8.
Hello, was there any progress related to this problem?
No, not since the last update on this ticket. Sorry.