Twiggy

0.5.1 · maintenance · verified Thu Apr 16

Twiggy is a Pythonic logging library that emphasizes structured logging and a fluid, method-chaining API. It aims to be more "Pythonic" than the standard library's `logging` module. The current version is 0.5.1, released on May 12, 2021. The library has a slow release cadence and is marked by its maintainers as "not rock solid (yet)", suggesting it is in a maintenance status rather than active, rapid development.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize Twiggy with default settings (console output) using `quick_setup()` and then log messages with bound names, structured fields, and different severity levels using the global `log` object. Twiggy supports `str.format()` style string formatting.

from twiggy import quick_setup, log

# Configure a basic console output
quick_setup()

# Log a message with structured fields
log.name('my_app').fields(user_id=123).info("User {user_id} logged in from {ip}", ip="192.168.1.100")

# Log a warning message
log.warning("Something unusual happened, but it's not critical.")

# Using the NOTICE level (added in 0.5.0)
log.notice("Heads up: An important event occurred.")

view raw JSON →