Created
March 31, 2011 13:48
-
-
Save rab/896368 to your computer and use it in GitHub Desktop.
temporarily change the logging level for the duration of a block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'logger' | |
module WithLogLevel | |
def with_log_level(level=Logger::INFO) | |
if logger | |
begin | |
original_level = logger.level | |
logger.level = level | |
yield | |
ensure | |
logger.level = original_level | |
end | |
else | |
yield | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment