Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang rebar, kernel options

I am trying to write simple erlang application, using rebar as eunit test runner. Is there any way to redirect annoying log messages into file, without doing it programmatically? Without rebar I can say erl -kernel error_logger "{file,\"test.log\"}" to do this, but how I can do it with rebar?

Generalizinig the question, is there any way to pass some application environment settings using rebar, when running tests?

like image 841
Viacheslav Kovalev Avatar asked Jan 26 '26 03:01

Viacheslav Kovalev


1 Answers

Answering to my own question. As discussed here, there is a way to pass erlang flags to rebar using ERL_AFLAGS environment variable. So it's possible to create config file with all necessary environment settings, and say ERL_AFLAGS="-config /path/to/config" rebar eunit.

Solution of my problem is:

echo '[{kernel, [{error_logger, {file, "test.log"}}]}].' > eunit.config
ERL_AFLAGS="-config eunit" rebar eunit

Think it is clumsy approach, but it just works.

like image 84
Viacheslav Kovalev Avatar answered Jan 28 '26 06:01

Viacheslav Kovalev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!