Skip to content

Instantly share code, notes, and snippets.

@rab
Created March 31, 2011 13:48
Show Gist options
  • Save rab/896368 to your computer and use it in GitHub Desktop.
Save rab/896368 to your computer and use it in GitHub Desktop.
temporarily change the logging level for the duration of a block
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