Background
I have library that logs messages depending on the value of disable_logging
:
unless Application.get(:my_app, :disable_logging, false), do:
Logger.info("Hello World!")
Depending on MIX_ENV
I have a config for each setup:
#test.config
use Mix.Config
config :my_app, disable_logging: true
Problem
The issue here is that I don't want log messages all over my test results. So, naturally, I could set the disable_logging
to true and be done with it.
However, if I do it, I can't test whether or not the Logger is being called and if it's being called with the correct values:
Question
So, given this I have some questions:
- Is there a way to activate logs but without outputting them to the terminal when I am running tests?
- Is there a way to only activate logs for some tests in my test suite?