When running tests in my Elixir mix app, I have a few instances where I include some calls to Logger.debug()
to monitor behavior. I find that, when I call mix test
from the command line, the Logger output is colored light-blue, and if I do something like add a custom color to the .debug()
call, the output is colored accordingly -
test "some behavior" do
Logger.debug("foo", ansi_color: :yellow)
assert true
end
writes the log lines in yellow, as expected.
However, I've noticed that if I run my tests from within an iex
session, the colors are not applied, just written to the terminal in the default font color (gray, in my case) -
iex(1)> Mix.shell().cmd(
"mix test --color",
env: [{"MIX_ENV", "test"}]
)
Why is it that running the tests from the bash command line results in colorful output, while running them from within iex results in my default font color?
For context - I'm running this on a Mac (Mojave), from the bash command line (as mentioned), Elixir version 1.8.1.
Admittedly, this is a fairly trivial matter in itself - but I'm trying to get a better understanding of the Elixir shell and Mix's various interactions with the shell and system, and cracking this might help me to get a better understanding of what's going on under the hood in general. It's not what I would expect to happen, I'd like to know why.