About This Talk
Logging is better than print(), but often the effort to set up and use the Python logging is perceived to be impractical. In this session we’ll review Python’s logging API, explore handling exceptions using logging, and discuss various configurations available in Django.
Outline
- Introduction
- Why Logging (your log calls annotate your code, etc.)
- Why Exceptions (because stuff breaks!)
- About me
- About Logging
- What is the logging API
- When to use it (anywhere you’d use print)
- Event Types - audit and diagnostic vs metrics
- About exceptions
- What are they
- Some common situations and what to handle
- General anatomy and some common types
- Making your own exceptions
- Python Logging
- Loggers
- Log Levels
- The LogRecord (the burrito with all the fillings)
- Formatters (read it your way)
- Handlers (put stuff where you want it)
- Filters (real power when you need it!)
- Logging and Exception Handling
- Getting a logger by __name__
- Writing to the logger
- Logging with exceptions
- logger.exception
- Raising with e
- Django Logging
- Django default logging
- Email and Console handlers
- Rollbar and log aggregaters
- Middleware and logging
- Revealing ORM SQL
- Custom logging configurations
- Adding a root logger
- Replacing sys.excepthook
- Controlling levels
- Custom formatters
- Bonus: Debugging! (time permitting)
- How to debug Django on Pycharm
- Questions
Presenters
Ryan Sullivan
Ryan Sullivan leads a team of three Django web developers at Wharton Research Data Services (WRDS. Prior to joined WRDS in 2012 as a web application developer, Ryan was a back-end Java Developer at Urban Outfitters and has worked in technology in Philadelphia for 16 years. Originally from Oakland California, when he’s not working, Ryan enjoys volunteering with Philadelphia non-profits, cycling, and traveling west frequently to visit family and friends.