用于阅读Erlang控制台或错误日志的工具

zrfyljdw  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(135)

我是新来的erlang和芝加哥老板一直在使用他们只有几个星期,所以我一直在使我的票价份额的错误,在这段时间。这并不困扰我那么多,因为它都是学习的一部分。
但让我感到沮丧的是控制台和错误日志,我发现它们几乎不可能阅读,因为每件事都在一行中出现,我不能区分堆栈消息的一个级别与另一个级别。更烦人的是,该字符串中有结构,但所有这些都被擦除。
有没有任何方式看到这些日志在一个更容易理解的形式,像php如何打印错误的网页,或打印_r函数的数组,也许有一些在芝加哥老板。

范例:

2014-07-22 16:30:54.285 [error] <0.784.0>@boss_web_controller:call_controller_action:366 Error in controller error undef 
[{simple_bridge_request_wrapper,post_param,
     [{simple_bridge_request_wrapper,mochiweb_request_bridge,
          {mochicow_request,#Port<0.41310>,'POST',"/greeting/list",
              'HTTP/1.1',
              {9,
               {"host",
                {"host","jason-virtualbox:8001"},
                {"accept",
                 {"accept",
                  "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"},
                 nil,
                 {"accept-language",
                  {"accept-language","en-US,en;q=0.5"},
                  {"accept-encoding",
                   {"accept-encoding","gzip, deflate"},
                   nil,nil},
                  {"connection",
                   {"connection","keep-alive"},
                   nil,
                   {"content-type",
                    {"content-type","application/x-www-form-urlencoded"},
                    {"content-length",{"content-length","44"},nil,nil},
                    nil}}}},
                {"user-agent",
                 {"user-agent",
                  "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0"},
                 {"referer",
                  {"referer","http://****:8001/greeting/hello"},
                  nil,nil},
                 nil}}},
              <<"SheetName=%7BBook1.2%7D%2C%7B0-Sheet1.csv%7D">>},
          false,[],[],none}],
     []},
 {pigeon_greeting_controller,list,3,
     [{file,
          "/home/jason/pigeon/src/controller/pigeon_greeting_controller.erl"},
      {line,34}]},
 {boss_web_controller,call_controller_action,3,
     [{file,"src/boss/boss_web_controller.erl"},{line,363}]},
 {boss_web_controller,apply_action,4,
     [{file,"src/boss/boss_web_controller.erl"},{line,355}]},
 {boss_web_controller,execute_action_inner,9,
     [{file,"src/boss/boss_web_controller.erl"},{line,334}]},
 {boss_web_controller_handle_request,process_dynamic_request,4,
     [{file,"src/boss/boss_web_controller_handle_request.erl"},{line,242}]},
 {boss_web_controller_handle_request,process_request,4,
     [{file,"src/boss/boss_web_controller_handle_request.erl"},{line,228}]},
 {boss_web_controller_handle_request,set_timer,7,
     [{file,"src/boss/boss_web_controller_handle_request.erl"},{line,148}]}]

任何帮助都会被挪用

tp5buhyn

tp5buhyn1#

如果他们把错误信息打印得很漂亮就好了,但是你也可以自己做,麻烦一点。消息的核心是一个Erlang术语,在本例中是一个列表。只需将Erlang术语复制并传递到你的shell中,添加一个句点,使其成为一个法律的的语句:

> [{simple_bridge_request_wrapper,post_param,[{simple_bridge_request_wrapper,mochiweb_request_bridge,{mochicow_request,#Port<0.41310>,'POST',"/greeting/list",'HTTP/1.1',{9,{"host",{"host","jason-virtualbox:8001"},{"accept",{"accept", "text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"},nil,{"accept-language",{"accept-language","en-US,en;q=0.5"},{"accept-encoding",{"accept-encoding","gzip, deflate"},nil,nil},{"connection",{"connection","keep-alive"},nil,{"content-type",{"content-type","application/x-www-form-urlencoded"},{"content-length",{"content-length","44"},nil,nil},nil}}}},{"user-agent",{"user-agent","Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0"},{"referer",{"referer","http://****:8001/greeting/hello"},nil,nil},nil}}},<<"SheetName=%7BBook1.2%7D%2C%7B0-Sheet1.csv%7D">>},false,[],[],none}],[]},{pigeon_greeting_controller,list,3,[{file,"/home/jason/pigeon/src/controller/pigeon_greeting_controller.erl"},{line,34}]},{boss_web_controller,call_controller_action,3,[{file,"src/boss/boss_web_controller.erl"},{line,363}]},{boss_web_controller,apply_action,4,[{file,"src/boss/boss_web_controller.erl"},{line,355}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,334}]},{boss_web_controller_handle_request,process_dynamic_request,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,242}]},{boss_web_controller_handle_request,process_request,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,228}]},{boss_web_controller_handle_request,set_timer,7,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,148}]}].

...然后按回车键:

* 1: syntax error before: '\\'

哎呀,显然在Erlang中没有端口的文字表示,所以他们打印了一个端口的简短描述:#Port<0.41310>。在Erlang中,您可以将非法字符用单引号括起来,我认为这可以创建一个Atom,这是一个合法的术语,因此shell将允许它:'#Port<0.41310>'。那么:

> [{simple_bridge_request_wrapper,post_param,[{simple_bridge_request_wrapper,mochiweb_request_bridge,{mochicow_request,'#Port<0.41310>','POST',"/greeting/list",'HTTP/1.1',{9,{"host",{"host","jason-virtualbox:8001"},{"accept",{"accept", "text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"},nil,{"accept-language",{"accept-language","en-US,en;q=0.5"},{"accept-encoding",{"accept-encoding","gzip, deflate"},nil,nil},{"connection",{"connection","keep-alive"},nil,{"content-type",{"content-type","application/x-www-form-urlencoded"},{"content-length",{"content-length","44"},nil,nil},nil}}}},{"user-agent",{"user-agent","Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0"},{"referer",{"referer","http://****:8001/greeting/hello"},nil,nil},nil}}},<<"SheetName=%7BBook1.2%7D%2C%7B0-Sheet1.csv%7D">>},false,[],[],none}],[]},{pigeon_greeting_controller,list,3,[{file,"/home/jason/pigeon/src/controller/pigeon_greeting_controller.erl"},{line,34}]},{boss_web_controller,call_controller_action,3,[{file,"src/boss/boss_web_controller.erl"},{line,363}]},{boss_web_controller,apply_action,4,[{file,"src/boss/boss_web_controller.erl"},{line,355}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,334}]},{boss_web_controller_handle_request,process_dynamic_request,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,242}]},{boss_web_controller_handle_request,process_request,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,228}]},{boss_web_controller_handle_request,set_timer,7,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,148}]}].

...然后按回车键:

[{simple_bridge_request_wrapper,post_param,
     [{simple_bridge_request_wrapper,mochiweb_request_bridge,
          {mochicow_request,'#Port<0.41310>','POST',"/greeting/list",
              'HTTP/1.1',
              {9,
               {"host",
                {"host","jason-virtualbox:8001"},
                {"accept",
                 {"accept",
                  "text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"},
                 nil,
                 {"accept-language",
                  {"accept-language","en-US,en;q=0.5"},
                  {"accept-encoding",{[...],...},nil,...},
                  {"connection",{...},...}}},
                {"user-agent",
                 {"user-agent",
                  "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0"},
                 {"referer",
                  {"referer","http://****:8001/greeting/hello"},
                  nil,nil},
                 nil}}},
              <<"SheetName=%7BBook1.2%7D%2C%7B0-Sheet1.csv%7D">>},
          false,[],[],none}],
     []},
 {pigeon_greeting_controller,list,3,
     [{file,
          "/home/jason/pigeon/src/controller/pigeon_greeting_controller.erl"},
      {line,34}]},
 {boss_web_controller,call_controller_action,3,
     [{file,"src/boss/boss_web_controller.erl"},{line,363}]},
 {boss_web_controller,apply_action,4,
     [{file,"src/boss/boss_web_controller.erl"},{line,355}]},
 {boss_web_controller,execute_action_inner,9,
     [{file,"src/boss/boss_web_controller.erl"},{line,334}]},
 {boss_web_controller_handle_request,process_dynamic_request,
     4,
     [{file,"src/boss/boss_web_controller_handle_request.erl"},
      {line,242}]},
 {boss_web_controller_handle_request,process_request,4,
     [{file,"src/boss/boss_web_controller_handle_request.erl"},
      {line,228}]},
 {boss_web_controller_handle_request,set_timer,7,
     [{file,"src/boss/boss_web_controller_handle_request.erl"},
      {line,148}]}]

我从来没有用过芝加哥Boss,所以我也帮不上忙。消息说undef,所以我想也许erlang找不到第一个函数。也许你还没有安装或编译simple_bridge_request_wrapper或其他什么?
显然,一直这样做会很烦人。也许有一种方法可以得到前面shell命令的输出。然后你可以写一个个人shell fun并把它放在你的user_default.erl中来自动化这个过程。或者如果你使用emacs,在elisp中做。或者修补CB来漂亮地打印它的错误消息。

相关问题