Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
One of the first things programmers do when software starts misbehaving is to stick in `print()` calls. This is great if you don't mind extra output, but there's a better way to get diagnostic info back from your app!
The Python logging
library docs
New terms:
- level - The level that you want to start logging messages at. Any message at this level or above will be logged.
- Logging Levels:
- CRITICAL
- ERROR
- WARNING
- INFO
- DEBUG
- NOTSET
Example:
import logging
try:
[1, 2, 3].remove(4)
except ValueError:
logging.error("tried to remove an invalid value")
print("Sorry, that value doesn't exist.")
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up