d-u-d-e / c-compiler

GNU General Public License v3.0
3 stars 0 forks source link

Optional logs #16

Open albertoursino opened 19 hours ago

albertoursino commented 19 hours ago

I was running the tests for the lexer (https://github.com/d-u-d-e/c-compiler/pull/6), and since we are calling the lexer run method which contains logger.info() calls, every test prints out logs. I'm not sure how useful they are during test runs. That said, I think it's useful to implement a way to turn off log messages when needed.

Maybe Loguru comes with a built-in function you can call at the top of a file that turns off the logs.

Another way is to give a parameter to the lexer run method, e.g. verbosity. But I prefer a solution like the one above.

albertoursino commented 19 hours ago

Here it is: https://loguru.readthedocs.io/en/stable/api/logger.html#loguru._logger.Logger.remove

You simply add this at the top of the file

# Disable all log messages
logger.remove()