Last active
January 24, 2017 19:44
-
-
Save mihow/b941536dae6e4bbc47196d08684de7dc to your computer and use it in GitHub Desktop.
Basic logging configuration in Python
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 | |
logging.basicConfig(format='%(levelname)s:%(message)s') | |
log = logging.getLogger(__name__) | |
log.setLevel(logging.INFO) | |
def main(): | |
log.info("Great info") | |
log.debug("You won't see this") | |
try: | |
log.blarg | |
except AttributeError: | |
log.exception("The exception below looks scary, but everything worked!") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment