Skip to content

Instantly share code, notes, and snippets.

@horpto horpto/block comment

Created Feb 11, 2015
Embed
What would you like to do?
function for required logging
from contextlib import contextmanager
from logging import getLogger, DEBUG, basicConfig
basicConfig(level = DEBUG)
@contextmanager
def comment(comment, logger=getLogger(),level=DEBUG):
try:
yield
except BaseException:
logger.log(level, "%s failed", comment)
raise
else:
logger.log(level, "%s done", comment)
with comment('test block', level=DEBUG):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.