d-u-d-e / c-compiler

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

Optional logs #16

Closed albertoursino closed 1 week ago

albertoursino commented 1 week ago

I ran the tests for the lexer (#6), and since each test invokes the run method of the lexer, which includes logger.info() calls, every test outputs log messages. These logs are highly useful in general, but they provide little value during test runs. When running multiple tests, they produce a flood of repetitive, “spam-like” messages. Given this, I think it would be useful to implement a mechanism to suppress log messages during test execution 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 1 week 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()