I want to filter the log errors generated by a mix task and write the selected error to a text file. How can I capture :stderr
or the logs? I was thinking about using ExUnit.capture_log
but when it captures stderr it does not echo it, which is problematic, seems my tasks run in a loop, the user would not get any feedback.
On unix, You can capture stderr with 2>. That would be
$ mix do_task > standard.txt 2> error.txt
Not working on windows of course…
1 Like
I would like to capture the output from the Elixir code, so that I can start my code from a mix task and not a shell script.
Yep, all easily done.
If you check the System.cmd/3
docs you’ll see how you can redirect the stdin and/or stderr among many other options.
So I need to start the mix task from another mix task?