-
-
Save m3adow/b96fa376d9f9e254b47f to your computer and use it in GitHub Desktop.
Logging - How does it work?
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
import logging | |
LOG = logging.getLogger('A') | |
ch = logging.StreamHandler() | |
formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s: %(message)s') | |
ch.setFormatter(formatter) | |
LOG.addHandler(ch) | |
LOG.setLevel("DEBUG") | |
from functions import common_functions | |
common_functions.loggertest() |
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
import logging | |
LOG = logging.getLogger('B') | |
ch = logging.StreamHandler() | |
formatter = logging.Formatter('%(levelname)s %(name)s: %(message)s %(asctime)s') | |
ch.setFormatter(formatter) | |
LOG.addHandler(ch) | |
LOG.setLevel("WARN") | |
from functions import common_functions | |
common_functions.loggertest() |
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
import logging | |
LOG = logging.getLogger('whichnamehere') | |
LOG.addHandler(logging.NullHandler()) | |
def loggertest(): | |
LOG.info("This should be printed with proper formatting.") | |
LOG.debug("This debug message as well.") | |
LOG.warn("This should be the only message visible for B.py") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment