2013-07-11 85 views
4

警告:erlang n00b提前。erlang中的截斷錯誤報告

我想要抓住erlang,只是嘗試一個基本的牛仔世界應用程序。我仿真錯誤,基本上在我的代碼某處返回一個無效的值,並試圖解釋錯誤,那就是:

=ERROR REPORT==== 11-Jul-2013::15:45:00 === 
Error in process <0.167.0> with exit value: {{try_clause,{ok, {http_req,#Port<0.3619>,ranch_tcp,keepalive,<0.167.0>,<<3 bytes>>,'HTTP/1.1', {{127,0,0,1},60312},<<9 bytes>>,undefined,8081,<<1 byte>>,undefined,<<0 bytes>>,undefined,[],[{<<10 bytes>>,<<11 bytes>>},{<<4 bytes>>,<<14 bytes>>},{<<6 bytes>>,<<3 bytes>>}],[],undefined,[],waiting,undefined,<<0 bytes>>,false,waiting,[],<<0 bytes>>,undefined}}}, [{cowboy_handler,handler_init,4,[... 

我設置我的應用程序有鋼筋,而我用它跑:

erl -pa ebin deps/*/ebin -s myapp 

正如你所看到的,錯誤以「...」結尾,這使我認爲它被截斷。有什麼方法可以打印完整的報告?

而且,有沒有什麼辦法讓它變得漂亮呢?

謝謝!

+0

嘗試增加'-boot start_sasl'到'erl'命令線;這應該會給你更詳細的錯誤報告。 – legoscia

+1

剛剛嘗試過,現在它也打印「進度報告」,但該錯誤仍然被截斷。 – Matt

回答

5

你看到的是sasl的tty處理函數。它格式化並將報告寫入控制檯。在格式化過程中,可能會削減一些有用的數據 爲了避免它,使用error_logger_mf_h處理程序是這樣的:

創建app.config文件的一些增值經銷商傳遞給SASL:

[ 

{sasl, [ 
    {sasl_error_logger, {file, "sasl.log"}}, 
    {errlog_type, all}, 
    {error_logger_mf_dir, "."}, % Log directory 
    {error_logger_mf_maxbytes, 10485760}, % 10 MB max file size 
    {error_logger_mf_maxfiles, 5} % 5 files max 
]} 

]. 

然後把ERL節點與開始SASL。日誌將被印製成sasl.log

erl -boot start_sasl -config app.config 
0

我相信沒有簡單的方法告訴sasl不要截斷錯誤報告。

您可以做的是爲報告創建自己的處理程序,並以不截斷的方式記錄錯誤。 (例如io:format("~p", [Error]))。

查看here作爲自定義報告處理程序的例子。

並且必須添加自定義處理程序的錯誤報告用戶:

error_logger:add_report_handler(?MODULE, []). 

或者你可以使用支持error_logger一個日誌庫。