Logging: a silent performance killer

Good find :thumbsup:
I always assumed that all debug log statements from my code were removed at compile time. I think :compile_time_purge_level should by default follow the Logger level.

:compile_time_purge_level - purges at compilation time all calls that have log level lower than the value of this option. This means that Logger calls with level lower than this option will be completely removed at compile time, accruing no overhead at runtime. Defaults to :debug and only applies to the Logger.debug/2, Logger.info/2, Logger.warn/2, and Logger.error/2 macros (e.g., it doesn’t apply to Logger.log/3. Note that arguments passed to Logger calls that are removed from the AST at compilation time are never evaluated, thus any function call that occurs in these arguments is never executed. As a consequence, avoid code that looks like Logger.debug(“Cleanup: #{perform_cleanup()}”) as in the example perform_cleanup/0 won’t be executed if the :compile_time_purge_level is :info or higher.