Created
February 11, 2015 06:47
-
-
Save horpto/ebc9ae920d91ebfadbce to your computer and use it in GitHub Desktop.
function for required logging
This file contains 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
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