Last active
August 29, 2015 14:05
-
-
Save themson/82be703b284af333e142 to your computer and use it in GitHub Desktop.
stub for using python logging object
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
import logging | |
def toggle_debug(debug_state): | |
logger = logging.getLogger(__file__) | |
if debug_state is True: | |
logger.setLevel(logging.DEBUG) | |
stream = logging.StreamHandler() | |
stream.setLevel(logging.NOTSET) | |
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s: "%(message)s"') | |
stream.setFormatter(formatter) | |
logger.addHandler(stream) | |
logger.debug("Debug Output: On") | |
else: | |
logger.setLevel(logging.NOTSET) | |
return logger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment