{"id":9372,"library":"twiggy","title":"Twiggy","description":"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.","status":"maintenance","version":"0.5.1","language":"python","source_language":"en","source_url":"https://github.com/wearpants/twiggy/","tags":["logging","logger","structured-logging"],"install":[{"cmd":"pip install Twiggy","lang":"bash","label":"Install latest stable version"}],"dependencies":[],"imports":[{"note":"Commonly imported alongside 'log' for initial configuration.","wrong":"import twiggy.quick_setup","symbol":"quick_setup","correct":"from twiggy import quick_setup"},{"note":"The primary logger instance. Often used after calling quick_setup().","wrong":"import twiggy.log","symbol":"log","correct":"from twiggy import log"},{"note":"Output classes reside in the `twiggy.outputs` submodule.","wrong":"from twiggy import FileOutput","symbol":"FileOutput","correct":"from twiggy.outputs import FileOutput"}],"quickstart":{"code":"from twiggy import quick_setup, log\n\n# Configure a basic console output\nquick_setup()\n\n# Log a message with structured fields\nlog.name('my_app').fields(user_id=123).info(\"User {user_id} logged in from {ip}\", ip=\"192.168.1.100\")\n\n# Log a warning message\nlog.warning(\"Something unusual happened, but it's not critical.\")\n\n# Using the NOTICE level (added in 0.5.0)\nlog.notice(\"Heads up: An important event occurred.\")","lang":"python","description":"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."},"warnings":[{"fix":"Evaluate suitability for your project's reliability requirements. Consider more mature logging solutions for high-stakes systems.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":"0.4.1 -> 0.5.x"},{"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.","message":"Twiggy'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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.5.1':36 '12':40 '2021':41 'activ':69 'aim':20 'api':18 'cadenc':48 'chain':17 'current':33 'develop':71 'emphas':9 'fluid':14 'librari':7,28,43 'log':6,11,30,72,76 'logger':73 'maintain':54 'mainten':65 'mark':51 'may':39 'method':16 'method-chain':15 'modul':31 'python':5,24 'rapid':70 'rather':67 'releas':37,47 'rock':57 'slow':46 'solid':58 'standard':27 'status':66 'structur':10,75 'structured-log':74 'suggest':60 'twiggi':1,2 'version':34 'yet':59","created_at":"2026-04-16T18:49:52.194899+00:00","updated_at":"2026-04-16T18:49:52.194899+00:00","problems":[{"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.","cause":"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.","error":"NameError: name 'log' is not defined"},{"fix":"Use a logging level method on the `log` object, e.g., `log.info(\"Your message here\")`, `log.debug(\"Another message\")`, etc.","cause":"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()`).","error":"TypeError: 'Message' object is not callable"},{"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.","cause":"Mixing up string formatting styles (e.g., using old-style `%` formatting with `str.format()` placeholders, or vice-versa).","error":"SyntaxError: invalid syntax (related to string formatting in log messages)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.5.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/wearpants/twiggy","docs":null,"changelog":null,"pypi":"https://pypi.org/project/twiggy/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}