Registry / observability / twiggy

twiggy

JSON →
library0.5.1pypypi✓ verified 87d ago

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.

pip install Twiggy
INSTALL
IMPORT
SIG · TWIGGY
T
twiggy
observabilitypythonv0.5.1
Install
1.6s avg
Import
64ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.068s · 18.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.059s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

quick_setup
from twiggy import quick_setup
import twiggy.quick_setup
Commonly imported alongside 'log' for initial configuration.
log
from twiggy import log
import twiggy.log
The primary logger instance. Often used after calling quick_setup().
FileOutput
from twiggy.outputs import FileOutput
from twiggy import FileOutput
Output classes reside in the `twiggy.outputs` submodule.

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.")
Debug
Known issues
gotchaThe official documentation states, 'Twiggy works great, but is not rock solid (yet); do not use for nuclear power plants, spaceships or mortgage derivatives trading.' This suggests caution for mission-critical applications.
fix
Evaluate suitability for your project's reliability requirements. Consider more mature logging solutions for high-stakes systems.
affects: All versions
breakingVersion 0.4.1's changelog mentions "deprecate features, pending a rewrite in 0.5". Users upgrading from versions prior to 0.5.0 that relied on these deprecated features may experience breakage.
fix
Consult the 0.5.0 changelog and API documentation to identify and update usage of any deprecated features. Review the `logging_compat` module if transitioning from standard library logging.
affects: 0.4.1 -> 0.5.x
gotchaTwiggy's `log` object needs to be imported (`from twiggy import log`) and often `quick_setup()` needs to be called to configure basic output before logging messages. Forgetting these steps leads to errors or no output.
fix
Always ensure `from twiggy import quick_setup, log` and `quick_setup()` are at the start of your application, or use `twiggy.setup()` for more granular control.
affects: All versions
Errors
Common errors & fixes
NameError: name 'log' is not defined
The global 'log' object or 'quick_setup' function was used without being imported, or the `quick_setup()` function was not called to initialize the logging system.
fix
Add `from twiggy import quick_setup, log` at the top of your file, and ensure `quick_setup()` is called once early in your application's lifecycle.
TypeError: 'Message' object is not callable
Attempting to call the `log` object directly like a function (`log("message")`) instead of calling one of its level-specific methods (e.g., `log.info()`, `log.warning()`).
fix
Use a logging level method on the `log` object, e.g., `log.info("Your message here")`, `log.debug("Another message")`, etc.
SyntaxError: invalid syntax (related to string formatting in log messages)
Mixing up string formatting styles (e.g., using old-style `%` formatting with `str.format()` placeholders, or vice-versa).
fix
Twiggy primarily uses `str.format()` style. Ensure your format string (`"hello {who}"`) matches the arguments (`who='world'`) and avoid mixing with C-style `%` formatting.
Upgrade
Version history
0.5.1latest on PyPI · released May 12, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
33 hits · last 30 days
node
30
OpenAI (training)
1
Resources
twiggy — pip install twiggy · libregistry