Logging and Exception Handling for Django

Monday 11:30 am to 12:20 pm, in Salon F-H
All

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

  1. Introduction
    1. Why Logging (your log calls annotate your code, etc.)
    2. Why Exceptions (because stuff breaks!)
    3. About me
  2. About Logging
    1. What is the logging API
    2. When to use it (anywhere you’d use print)
    3. Event Types - audit and diagnostic vs metrics
  3. About exceptions
    1. What are they
    2. Some common situations and what to handle
    3. General anatomy and some common types
    4. Making your own exceptions
  4. Python Logging
    1. Loggers
    2. Log Levels
    3. The LogRecord (the burrito with all the fillings)
    4. Formatters (read it your way)
    5. Handlers (put stuff where you want it)
    6. Filters (real power when you need it!)
  5. Logging and Exception Handling
    1. Getting a logger by __name__
    2. Writing to the logger
    3. Logging with exceptions
    4. logger.exception
    5. Raising with e
  6. Django Logging
    1. Django default logging
    2. Email and Console handlers
    3. Rollbar and log aggregaters
    4. Middleware and logging
    5. Revealing ORM SQL
  7. Custom logging configurations
    1. Adding a root logger
    2. Replacing sys.excepthook
    3. Controlling levels
    4. Custom formatters
  8. Bonus: Debugging! (time permitting)
    1. How to debug Django on Pycharm
  9. Questions

Presenters

    Photo of

    Ryan Sullivan