Twiggy: The First New Logger in Fifteen Years
*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
- me, the project, where to find it, status
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
- first new logger in 15 years (since log4j)
- stay out of your way
Demo
- Demonstration of twiggy in an ‘interactive’ shell
Basic Use
Structured Logging
- what it is, why it’s useful
Sample Output
- what it looks like
Configuration
Modern Loose Coupling
- django URLconf inspired
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
- optional add-ins of common logging patterns
- dynamic messages
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?
Tags
python logging twiggy
Speaking experience
Speaker
-
- Website: http://i.wearpants.org/
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:00 – 9: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:00 – 8: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