erlang-lager / lager

A logging framework for Erlang/OTP
Apache License 2.0
1.12k stars 456 forks source link

Unicode problems? #448

Closed davidwowa closed 6 years ago

davidwowa commented 6 years ago

Here is my error report:

2018-03-21 00:01:13 =ERROR REPORT==== ** gen_event handler {lager_file_backend,"log/console.log"} crashed. ** Was installed in lager_event ** Last event was: {log,{lager_msg,[],[{application,blockchain},{module,ws_handler},{function,terminate},{line,41},{pid,"<0.11250.0>"},{node,nonode@nohost}],info,{["2018",45,"03",45,"21"],["00",58,"01",58,"13",46,"229"]},{1521,586873,229857},{crash,error,{badmatch,{error,enoent}}}}} ** When handler state == {state,"log/console.log",{mask,127},{file_descriptor,prim_file,{#Port<0.651800>,38}},24285019,false,10485760,[{hour,0}],5,lager_rotator_default,{lager_shaper,"log/console.log",undefined,0,{1521,586725,110873},0,true,0,#Ref<0.1198586251.2507931650.164416>,#Fun<lager_file_backend.0.86890548>},lager_default_formatter,[],{mask,15},1000,1000,65536,{1521,586873,206059}} ** Reason == {badarg,[{unicode,characters_to_binary,[[["2018",45,"03",45,"21"]," ",["00",58,"01",58,"13",46,"229"]," ",[],"[","info","] ","<0.11250.0>",[["@"],"ws_handler",[":","terminate"],[":",["41"]]]," ",{crash,error,{badmatch,{error,enoent}}},"\n"]],[]},{lager_file_backend,do_write,3,[{file,"/Users/David/IdeaProjects/bc/_build/default/lib/lager/src/lager_file_backend.erl"},{line,278}]},{lager_file_backend,handle_event,2,[{file,"/Users/David/IdeaProjects/bc/_build/default/lib/lager/src/lager_file_backend.erl"},{line,177}]},{gen_event,server_update,4,[{file,"gen_event.erl"},{line,573}]},{gen_event,server_notify,4,[{file,"gen_event.erl"},{line,555}]},{gen_event,handle_msg,6,[{file,"gen_event.erl"},{line,296}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}

Why I think that problem is with unicode:

** Reason == {badarg,[{unicode,characters_to_binary,[[["2018",45,"03",45,"21"]...

Here my configuration in rebar:

{lager, {git, "https://github.com/erlang-lager/lager", {tag, "3.6.1"}}}

and

{lager, [ {log_root, "log"}, {handlers, [ {lager_console_backend, [{level, debug}]}, {lager_file_backend, [{file, "error.log"}, {level, error}]}, {lager_file_backend, [{file, "info.log"}, {level, info}]}, {lager_file_backend, [{file, "debug.log"}, {level, debug}]} ]} ]}.

jadeallenx commented 6 years ago

Might be a unicode problem. Goodness knows that lager has never been especially good at handling unicode text.

But it looks to me like the invalid "unicode" [{unicode,characters_to_binary,[[["2018",45,"03",45,"21"]... is a datetime stamp that has somehow been interpreted as a potential unicode byte sequence for a file name. (ASCII 45 is the "-" character, so it would be 2018-03-21 as a string)

jadeallenx commented 6 years ago

Any update on this issue?

jadeallenx commented 6 years ago

I'm going to close this issue because there's been no updates for several months. Please open a new ticket if you still need help.

llelf commented 5 years ago

Not Unicode. It tries to do

unicode:characters_to_binary([
  ["2018",45,"03",45,"21"]," ",
  ["00",58,"01",58,"13",46,"229"]," ",[],"[","info","] ",
  "<0.11250.0>",[["@"],"ws_handler",[":","terminate"],[":",["41"]]],
  " ",
  {crash,error,{badmatch,{error,enoent}}},  % ⟵ 
  "\n"
]).