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

时间:2014-07-21 02:07:06

标签: erlang chicagoboss

我是erlang的新手,芝加哥Boss一直使用它们只有几个星期,所以我在那个时候一直在犯错误。这并不会让我感到困扰,因为它是学习的全部内容。

但令我感到沮丧的是控制台和错误日志,我发现它们几乎不可能读取,因为每一件事都出现在一行中而我无法告诉一个层次的堆栈消息。更令人讨厌的是,该字符串中有结构,但所有这些都被抹去了。

有没有看到这些日志以更易理解的形式出现,比如php如何将错误打印到网页,或者数组的print_r函数,也许芝加哥老板也有一些东西。

示例:
2014-07-22 16:30:54.285 [错误]&lt; 0.784.0&gt; @boss_web_controller:call_controller_action:366控制器错误中的错误undef [{simple_bridge_request_wrapper,post_param,[{simple_bridge_request_wrapper,mochiweb_request_bridge,{mochicow_request,#Port&lt; 0.41310&gt; ;, 'POST', “/问候/清单”, 'HTTP / 1.1',{9,{ “宿主”,{ “宿主”, “杰森-的virtualbox:8001”},{ “接受”,{ “接受” “text / html的,应用/ XHTML + xml的,应用/ XML; q = 0.9, / 的; q = 0.8”},零,{ “接受 - 语言”,{ “接受 - 语言” ,“en-US,en; q = 0.5”},{“accept-encoding”,{“accept-encoding”,“gzip,deflate”},nil,nil},{“connection”,{“connection”, “保持活跃”},零,{“内容类型”,{“内容类型”,“应用程序/ x WWW的形式进行了urlencoded”},{“内容长度”,{“内容长度”, “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“&GT;&GT;},假,[],[],无}], []},{pigeon_greeting_controller,列表3,[{文件, “/家庭/杰森/鸽/ SRC /控制器/ pigeon_greeting_controller.erl”},{线,34}]},{boss_web_controller,call_controller_action,3,[{文件, “SRC /老板/ boss_web_controller.erl”},{线,363}]},{boss_web_controller,apply_action,4,[{文件, “SRC /老板/ boss_web_controller.erl”},{线,355}]} {boss_web_controller,execute_action_inner,9,[{文件, “SRC /老板/ boss_web_controller.erl”},{线,334}]},{boss_web_controller_handle_request,process_dynamic_request,4,[{文件,“SRC /老板/ boss_web_controller_handle_request.erl “},{线,242}]},{boss_web_controller_handle_request,process_request,4,[{文件,” SRC /老板/ boss_web_controller_handle_request.erl“},{线,228}]},{boss_web_controller_handle_request,SET_TIMER,7,[{文件, “SRC /老板/ boss_web_controller_handle_request.erl”},{线,148}]}]

任何帮助都会被挪用

1 个答案:

答案 0 :(得分:1)

如果他们打印错误消息会很好,但你可以自己做一些麻烦。消息的内容是一个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中,您可以将非法字符包装在单引号中我认为创建一个原子,这是一个合法术语,因此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}]}]

我从未使用芝加哥老板,所以我无法帮助。消息说undef所以这让我觉得也许erlang无法找到第一个功能。也许你还没有安装或编译simple_bridge_request_wrapper或什么?

显然,这一直都很烦人。也许有办法获得前一个shell命令的输出。然后,您可以编写个人shell乐趣并将其放在user_default.erl中以自动执行此过程。或者如果您使用emacs,请在elisp中执行此操作。或者修补CB以打印其错误消息。