Twiggy: The First New Logger in Fifteen Years

*
Proposal
Short Form
Scheduled: Thursday, June 23, 2011 from 11:00 – 11:45am in B201

Excerpt

Twiggy is a Pythonic logger. The first new design for a logger in any language in 15 years, it supports powerful structured logging, modern loosely coupled configuration and sophisticated features to make logging fun, fast and easy. This talk will introduce Twiggy, demonstrate its basic and advanced uses, and compare it to other logging packages. Learn more at twiggy.wearpants.org

Description

Intro

Origin Myth

  • started at Pycon 2010 at Jesse Noller’s urging
  • whine → beer → project → oops
  • doing this for the community

Why Logging Matters

  • your only source of data about your application
  • what logging is useful for

Why Logging is Insane

  • it’s a giant global
  • you want to change the behavior of libraries you don’t control and don’t care about your application (e.g., adding web request_id to database logs)
  • you need dynamic scoping

From the Ground Up: Reimagining Logging

Demo

Basic Use

Structured Logging

Sample Output

  • what it looks like

Configuration

Modern Loose Coupling

Outputs

  • highlight of output backends: syslog, email, HTTP, etc.
  • Asynchronous output moves the expensive write operation to a separate process
  • lazy logging – group messages together + conditional output

Formatting

  • highlight of customizing formatting
  • how structured logging makes sophisticated formatting possible

Comparisons

Benchmarks

  • raw performance
  • impact on a real application – simulated multi-threaded webserver

vs. log4j style (Python’s stdlib logging)

  • side-by-side code
  • benchmark comparison
  • compatibility layer allows Twiggy to be dropped in for stdlib logging

Advanced Uses (5 min)

Context-aware

  • injecting info into messages per thread/per process
  • killer feature for webapps

Dynamic, Features

Unittest Support

  • assert that your code generates the correct logs

Helper Utilities

  • highlights of decorators, context managers, etc. for common tasks

Coda

Lessons Learned

  • when designing code, be aware of the past, but not too aware

Doing it for the Community

  • inspirations: Tarek Ziadé, Jesse Noller, Karl Carsten, Ian Bicking
  • what can you do for your communities?

Speaking experience

Speaker

  • Photo 42

    Biography

    I wear pants.

    I also code python, hack preconceived notions, cook and ride bikes.

    Sessions

      • Title: Morning Keynote - Hacking for Freedom
      • Track: Culture
      • Room: Sanctuary
      • Time: 9:009:45am
      • Excerpt:

        The last year has shown the Internet and computers to be a major force for freedom and self-determination around the world. The presenter discusses his work as a hacktivist. Working with Anonymous and Telecomix, he has helped organized protests in support of WikiLeaks, provided communications support to Egypt and the Middle East, and generally fought the good fight.

      • Speakers: Peter Fein
      • Title: A Guided Tour of IRC
      • Track: BOF
      • Room: B302/03
      • Time: 7:008:30pm
      • Excerpt:

        Introduction to IRC for new users, entertainment for veterans. Learn basics, safety, security. Hang out interesting places, we’ll visit Freenode, Telecomix, Anonymous, Wikileaks.

      • Speakers: Peter Fein