structlog


Namestructlog JSON
Version 25.1.0 PyPI version JSON
download
home_pageNone
SummaryStructured Logging for Python
upload_time2025-01-16 13:04:09
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords log logging structure structured
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
    <img
        src="https://www.structlog.org/en/stable/_static/structlog_logo_small.png"
        alt="structlog mascot"
    />
</p>

*structlog* is *the* production-ready logging solution for Python:

- **Simple**: Everything is about **functions** that take and return **dictionaries** – all hidden behind **familiar APIs**.
- **Powerful**: Functions and dictionaries aren’t just simple but also powerful.
  *structlog* leaves *you* in control.
- **Fast**: *structlog* is not hamstrung by designs of yore.
  Its flexibility comes not at the price of performance.

Thanks to its flexible design, *you* choose whether you want *structlog* to take care of the **output** of your log entries or whether you prefer to **forward** them to an existing logging system like the standard library's `logging` module.

The output format is just as flexible and *structlog* comes with support for JSON, [*logfmt*](https://brandur.org/logfmt), as well as pretty console output out-of-the-box:

[![image](https://github.com/hynek/structlog/blob/main/docs/_static/console_renderer.png?raw=true)](https://github.com/hynek/structlog/blob/main/docs/_static/console_renderer.png?raw=true)


## Sponsors

*structlog* would not be possible without our [amazing sponsors](https://github.com/sponsors/hynek).
Especially those generously supporting us at the *The Organization* tier and higher:

<!-- pause-short -->

<p align="center">

<!-- [[[cog
import pathlib, tomllib

for sponsor in tomllib.loads(pathlib.Path("pyproject.toml").read_text())["tool"]["sponcon"]["sponsors"]:
      print(f'<a href="{sponsor["url"]}"><img title="{sponsor["title"]}" src="https://www.structlog.org/en/25.1.0/_static/sponsors/{sponsor["img"]}" width="190" /></a>')
]]] -->
<a href="https://www.variomedia.de/"><img title="Variomedia AG" src="https://www.structlog.org/en/25.1.0/_static/sponsors/Variomedia.svg" width="190" /></a>
<a href="https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek"><img title="Tidelift" src="https://www.structlog.org/en/25.1.0/_static/sponsors/Tidelift.svg" width="190" /></a>
<a href="https://klaviyo.com/"><img title="Klaviyo" src="https://www.structlog.org/en/25.1.0/_static/sponsors/Klaviyo.svg" width="190" /></a>
<a href="https://www.emsys-renewables.com/"><img title="emsys renewables" src="https://www.structlog.org/en/25.1.0/_static/sponsors/emsys-renewables.svg" width="190" /></a>
<a href="https://filepreviews.io/"><img title="FilePreviews" src="https://www.structlog.org/en/25.1.0/_static/sponsors/FilePreviews.svg" width="190" /></a>
<a href="https://polar.sh/"><img title="Polar" src="https://www.structlog.org/en/25.1.0/_static/sponsors/Polar.svg" width="190" /></a>
<!-- [[[end]]] -->

</p>

<!-- continue-short -->

<p align="center">
   <strong>Please consider <a href="https://github.com/sponsors/hynek">joining them</a> to help make <em>structlog</em>’s maintenance more sustainable!</strong>
</p>

## Introduction

*structlog* has been successfully used in production at every scale since **2013**, while embracing cutting-edge technologies like *asyncio*, context variables, or type hints as they emerged.
Its paradigms proved influential enough to [help design](https://twitter.com/sirupsen/status/638330548361019392) structured logging [packages across ecosystems](https://github.com/sirupsen/logrus).

## Project Links

- [**Get Help**](https://stackoverflow.com/questions/tagged/structlog) (use the *structlog* tag on Stack Overflow)
- [**PyPI**](https://pypi.org/project/structlog/)
- [**GitHub**](https://github.com/hynek/structlog)
- [**Documentation**](https://www.structlog.org/)
- [**Changelog**](https://github.com/hynek/structlog/tree/main/CHANGELOG.md)
- [**Third-party Extensions**](https://github.com/hynek/structlog/wiki/Third-party-Extensions)


## *structlog* for Enterprise

Available as part of the [Tidelift Subscription](https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek).

The maintainers of *structlog* and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications.
Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use.


## Release Information

### Added

- Add `structlog.stdlib.render_to_log_args_and_kwargs` processor.
  Same as `structlog.stdlib.render_to_log_kwargs`, but also allows to pass positional arguments to `logging`.
  With it, you do not need to add `structlog.stdlib.PositionalArgumentsFormatter` processor to format positional arguments from *structlog* loggers.
  [#668](https://github.com/hynek/structlog/pull/668)

- Native loggers now have `is_enabled_for()` and `get_effective_level()` methods that mirror the behavior of the standard library's `logging.Logger.isEnabledFor()` and `logging.Logger.getEffectiveLevel()`.
  [#689](https://github.com/hynek/structlog/pull/689)


### Changed

- `structlog.typing.BindableLogger` protocol now returns `Self` instead of `BindableLogger`.
  This adds a dependency on [*typing-extensions*](https://pypi.org/project/typing-extensions/) for Pythons older than 3.11.
  [#642](https://github.com/hynek/structlog/pull/642)
  [#659](https://github.com/hynek/structlog/pull/659)

- `structlog.dev.ConsoleRenderer` will quote string value with special characters.
  [#647](https://github.com/hynek/structlog/pull/647)

- `structlog.stdlib.recreate_defaults()` now also adds `structlog.stdlib.PositionalArgumentsFormatter`.
  In default native mode, this is done by the loggers at the edge.

- `structlog.make_filtering_bound_logger()` now also accepts a string for *min_level*.


### Fixed

- Fix handling calls to `{logger}.exception()` outside of exception blocks.
  Depending on the structlog configuration,
  this either resulted in an event dict key `exception: "MISSING"` or lead to an error.
  Now, an invalid or missing `exc_info` will just be ignored.
  This means, that calling `{logger}.exception()` outside of an exception block is basically the same as calling `{logger}.error()`.
  [#634](https://github.com/hynek/structlog/issues/634)
  [#680](https://github.com/hynek/structlog/pull/680)

- Instantiating `structlog.dev.ConsoleRenderer` does not mutate the passed *styles* dict anymore.
  [#669](https://github.com/hynek/structlog/pull/669)

- The native `FilteringBoundLogger.fatal()` method now maps to the critical level, as it does in the standard library.
  Note that the level is discouraged to use there, so we recommend to stick to `error()` or `critical()`.
  [#677](https://github.com/hynek/structlog/pull/677)

- `structlog.tracebacks.ExceptionDictTransformer` now actually accepts `None` for `locals_max_length` and `locals_max_string`.
  [#675](https://github.com/hynek/structlog/pull/675)


---

[Full Changelog →](https://www.structlog.org/en/stable/changelog.html)


## Credits

*structlog* is written and maintained by [Hynek Schlawack](https://hynek.me/).
The idea of bound loggers is inspired by previous work by [Jean-Paul Calderone](https://github.com/exarkun) and [David Reid](https://github.com/dreid).

The development is kindly supported by my employer [Variomedia AG](https://www.variomedia.de/), *structlog*’s [Tidelift subscribers](https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek), and all my amazing [GitHub Sponsors](https://github.com/sponsors/hynek).

The logs-loving beaver logo has been contributed by [Lynn Root](https://www.roguelynn.com).



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "structlog",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "log, logging, structure, structured",
    "author": null,
    "author_email": "Hynek Schlawack <hs@ox.cx>",
    "download_url": "https://files.pythonhosted.org/packages/25/fe/578db23e17392a8693b45a7b7dc6985370f51dd937157def8ecc7b20930d/structlog-25.1.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n    <img\n        src=\"https://www.structlog.org/en/stable/_static/structlog_logo_small.png\"\n        alt=\"structlog mascot\"\n    />\n</p>\n\n*structlog* is *the* production-ready logging solution for Python:\n\n- **Simple**: Everything is about **functions** that take and return **dictionaries** \u2013 all hidden behind **familiar APIs**.\n- **Powerful**: Functions and dictionaries aren\u2019t just simple but also powerful.\n  *structlog* leaves *you* in control.\n- **Fast**: *structlog* is not hamstrung by designs of yore.\n  Its flexibility comes not at the price of performance.\n\nThanks to its flexible design, *you* choose whether you want *structlog* to take care of the **output** of your log entries or whether you prefer to **forward** them to an existing logging system like the standard library's `logging` module.\n\nThe output format is just as flexible and *structlog* comes with support for JSON, [*logfmt*](https://brandur.org/logfmt), as well as pretty console output out-of-the-box:\n\n[![image](https://github.com/hynek/structlog/blob/main/docs/_static/console_renderer.png?raw=true)](https://github.com/hynek/structlog/blob/main/docs/_static/console_renderer.png?raw=true)\n\n\n## Sponsors\n\n*structlog* would not be possible without our [amazing sponsors](https://github.com/sponsors/hynek).\nEspecially those generously supporting us at the *The Organization* tier and higher:\n\n<!-- pause-short -->\n\n<p align=\"center\">\n\n<!-- [[[cog\nimport pathlib, tomllib\n\nfor sponsor in tomllib.loads(pathlib.Path(\"pyproject.toml\").read_text())[\"tool\"][\"sponcon\"][\"sponsors\"]:\n      print(f'<a href=\"{sponsor[\"url\"]}\"><img title=\"{sponsor[\"title\"]}\" src=\"https://www.structlog.org/en/25.1.0/_static/sponsors/{sponsor[\"img\"]}\" width=\"190\" /></a>')\n]]] -->\n<a href=\"https://www.variomedia.de/\"><img title=\"Variomedia AG\" src=\"https://www.structlog.org/en/25.1.0/_static/sponsors/Variomedia.svg\" width=\"190\" /></a>\n<a href=\"https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek\"><img title=\"Tidelift\" src=\"https://www.structlog.org/en/25.1.0/_static/sponsors/Tidelift.svg\" width=\"190\" /></a>\n<a href=\"https://klaviyo.com/\"><img title=\"Klaviyo\" src=\"https://www.structlog.org/en/25.1.0/_static/sponsors/Klaviyo.svg\" width=\"190\" /></a>\n<a href=\"https://www.emsys-renewables.com/\"><img title=\"emsys renewables\" src=\"https://www.structlog.org/en/25.1.0/_static/sponsors/emsys-renewables.svg\" width=\"190\" /></a>\n<a href=\"https://filepreviews.io/\"><img title=\"FilePreviews\" src=\"https://www.structlog.org/en/25.1.0/_static/sponsors/FilePreviews.svg\" width=\"190\" /></a>\n<a href=\"https://polar.sh/\"><img title=\"Polar\" src=\"https://www.structlog.org/en/25.1.0/_static/sponsors/Polar.svg\" width=\"190\" /></a>\n<!-- [[[end]]] -->\n\n</p>\n\n<!-- continue-short -->\n\n<p align=\"center\">\n   <strong>Please consider <a href=\"https://github.com/sponsors/hynek\">joining them</a> to help make <em>structlog</em>\u2019s maintenance more sustainable!</strong>\n</p>\n\n## Introduction\n\n*structlog* has been successfully used in production at every scale since **2013**, while embracing cutting-edge technologies like *asyncio*, context variables, or type hints as they emerged.\nIts paradigms proved influential enough to [help design](https://twitter.com/sirupsen/status/638330548361019392) structured logging [packages across ecosystems](https://github.com/sirupsen/logrus).\n\n## Project Links\n\n- [**Get Help**](https://stackoverflow.com/questions/tagged/structlog) (use the *structlog* tag on Stack Overflow)\n- [**PyPI**](https://pypi.org/project/structlog/)\n- [**GitHub**](https://github.com/hynek/structlog)\n- [**Documentation**](https://www.structlog.org/)\n- [**Changelog**](https://github.com/hynek/structlog/tree/main/CHANGELOG.md)\n- [**Third-party Extensions**](https://github.com/hynek/structlog/wiki/Third-party-Extensions)\n\n\n## *structlog* for Enterprise\n\nAvailable as part of the [Tidelift Subscription](https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek).\n\nThe maintainers of *structlog* and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications.\nSave time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use.\n\n\n## Release Information\n\n### Added\n\n- Add `structlog.stdlib.render_to_log_args_and_kwargs` processor.\n  Same as `structlog.stdlib.render_to_log_kwargs`, but also allows to pass positional arguments to `logging`.\n  With it, you do not need to add `structlog.stdlib.PositionalArgumentsFormatter` processor to format positional arguments from *structlog* loggers.\n  [#668](https://github.com/hynek/structlog/pull/668)\n\n- Native loggers now have `is_enabled_for()` and `get_effective_level()` methods that mirror the behavior of the standard library's `logging.Logger.isEnabledFor()` and `logging.Logger.getEffectiveLevel()`.\n  [#689](https://github.com/hynek/structlog/pull/689)\n\n\n### Changed\n\n- `structlog.typing.BindableLogger` protocol now returns `Self` instead of `BindableLogger`.\n  This adds a dependency on [*typing-extensions*](https://pypi.org/project/typing-extensions/) for Pythons older than 3.11.\n  [#642](https://github.com/hynek/structlog/pull/642)\n  [#659](https://github.com/hynek/structlog/pull/659)\n\n- `structlog.dev.ConsoleRenderer` will quote string value with special characters.\n  [#647](https://github.com/hynek/structlog/pull/647)\n\n- `structlog.stdlib.recreate_defaults()` now also adds `structlog.stdlib.PositionalArgumentsFormatter`.\n  In default native mode, this is done by the loggers at the edge.\n\n- `structlog.make_filtering_bound_logger()` now also accepts a string for *min_level*.\n\n\n### Fixed\n\n- Fix handling calls to `{logger}.exception()` outside of exception blocks.\n  Depending on the structlog configuration,\n  this either resulted in an event dict key `exception: \"MISSING\"` or lead to an error.\n  Now, an invalid or missing `exc_info` will just be ignored.\n  This means, that calling `{logger}.exception()` outside of an exception block is basically the same as calling `{logger}.error()`.\n  [#634](https://github.com/hynek/structlog/issues/634)\n  [#680](https://github.com/hynek/structlog/pull/680)\n\n- Instantiating `structlog.dev.ConsoleRenderer` does not mutate the passed *styles* dict anymore.\n  [#669](https://github.com/hynek/structlog/pull/669)\n\n- The native `FilteringBoundLogger.fatal()` method now maps to the critical level, as it does in the standard library.\n  Note that the level is discouraged to use there, so we recommend to stick to `error()` or `critical()`.\n  [#677](https://github.com/hynek/structlog/pull/677)\n\n- `structlog.tracebacks.ExceptionDictTransformer` now actually accepts `None` for `locals_max_length` and `locals_max_string`.\n  [#675](https://github.com/hynek/structlog/pull/675)\n\n\n---\n\n[Full Changelog \u2192](https://www.structlog.org/en/stable/changelog.html)\n\n\n## Credits\n\n*structlog* is written and maintained by [Hynek Schlawack](https://hynek.me/).\nThe idea of bound loggers is inspired by previous work by [Jean-Paul Calderone](https://github.com/exarkun) and [David Reid](https://github.com/dreid).\n\nThe development is kindly supported by my employer [Variomedia AG](https://www.variomedia.de/), *structlog*\u2019s [Tidelift subscribers](https://tidelift.com/?utm_source=lifter&utm_medium=referral&utm_campaign=hynek), and all my amazing [GitHub Sponsors](https://github.com/sponsors/hynek).\n\nThe logs-loving beaver logo has been contributed by [Lynn Root](https://www.roguelynn.com).\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Structured Logging for Python",
    "version": "25.1.0",
    "project_urls": {
        "Bluesky": "https://bsky.app/profile/hynek.me",
        "Changelog": "https://github.com/hynek/structlog/blob/main/CHANGELOG.md",
        "Documentation": "https://www.structlog.org/",
        "Funding": "https://github.com/sponsors/hynek",
        "GitHub": "https://github.com/hynek/structlog",
        "Mastodon": "https://mastodon.social/@hynek",
        "Tidelift": "https://tidelift.com?utm_source=lifter&utm_medium=referral&utm_campaign=hynek",
        "Twitter": "https://twitter.com/hynek"
    },
    "split_keywords": [
        "log",
        " logging",
        " structure",
        " structured"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c114e9aed6c820fa166e8a19a19e663e98bd5538004d68a70c5752458ca3656e",
                "md5": "f9694eb19a46db7e915a3a3f35f8f134",
                "sha256": "843fe4f254540329f380812cbe612e1af5ec5b8172205ae634679cd35a6d6321"
            },
            "downloads": -1,
            "filename": "structlog-25.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f9694eb19a46db7e915a3a3f35f8f134",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 68921,
            "upload_time": "2025-01-16T13:04:06",
            "upload_time_iso_8601": "2025-01-16T13:04:06.690024Z",
            "url": "https://files.pythonhosted.org/packages/c1/14/e9aed6c820fa166e8a19a19e663e98bd5538004d68a70c5752458ca3656e/structlog-25.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25fe578db23e17392a8693b45a7b7dc6985370f51dd937157def8ecc7b20930d",
                "md5": "85b777bef382feb3b52a6950b5223392",
                "sha256": "2ef2a572e0e27f09664965d31a576afe64e46ac6084ef5cec3c2b8cd6e4e3ad3"
            },
            "downloads": -1,
            "filename": "structlog-25.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "85b777bef382feb3b52a6950b5223392",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 1364973,
            "upload_time": "2025-01-16T13:04:09",
            "upload_time_iso_8601": "2025-01-16T13:04:09.792488Z",
            "url": "https://files.pythonhosted.org/packages/25/fe/578db23e17392a8693b45a7b7dc6985370f51dd937157def8ecc7b20930d/structlog-25.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-16 13:04:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hynek",
    "github_project": "structlog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "structlog"
}
        
Elapsed time: 0.41327s