5

Warning: erlang n00b ahead.

I'm trying to get a grasp of erlang, and just trying a basic hello world application with cowboy. I'm simulating an error, basically returning an invalid value somewhere in my code, and trying to interpret the error, which is:

=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,[...

I've setup my application with rebar, and I'm running it with:

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

As you can see, the error ends with "..." which makes me think it is being truncated. Is there any way to print the full report?

And, is there any way to make it pretty-print it?

Thanks!

Matt
  • 1,313
  • 4
  • 17
  • 27
  • Try adding `-boot start_sasl` to the `erl` command line; that should give you more verbose error reports. – legoscia Jul 11 '13 at 15:00
  • 1
    Just tried it and now it prints "progress reports" also, but that error is still being truncated. – Matt Jul 11 '13 at 15:49

3 Answers3

5

What you see is sasl's tty handler. It formats and writes reports to console. During formatting it could cut some useful data. To avoid it, use error_logger_mf_h handler like this:

Create app.config file to pass some vars to 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
]}

].

Then bring erl node with started sasl. Logs will be printed into sasl.log

erl -boot start_sasl -config app.config
danechkin
  • 1,306
  • 8
  • 15
2

The error message is truncated by the Erlang emulator, so there is no way to get the full message from sasl. There is an undocumented switch that you can use to see more of the message. "erl +# 400" truncate at 400 instead of 200 characters.

More details: http://erlang.org/pipermail/erlang-questions/2014-October/081442.html

ransomr
  • 171
  • 2
1

I believe there is no easy way of telling sasl to not truncate the error report.

What you could do is create your own handler for the reports and log the error in a way that it is not truncated. (e.g. io:format("~p", [Error])).

Look here for an exemple of custom report handler.

And you must add your custom handler as a subscriber of error reports:

error_logger:add_report_handler(?MODULE, []).

Or you could use a logging library that supports error_logger.

Isac
  • 2,058
  • 16
  • 23