At times you may want to temporarily silence or adjust the log level.
How to use it
1 2 3 4 5 6 7 8 9
logger.level = :info # silence, by default, raises the level to error logger.silence do logger.info("info message") # will _not_ be logged logger.error("error message") # _will_ be logged end logger.info("info message") # _will_ be logged
You can also specify a different level:
1 2 3
logger.silence(Logger::FATAL) do logger.error("error message") # will _not_ be logged end
How it works
This is currently accomplished by using the ActiveSupport
LoggerSilence module, which means you must have ActiveSupport included as a dependency if you'd like to use this. If you are not on Rails and want access to this feature, please open an issue to provide this feature directly in the
timber library itself.