{"id":50307305,"url":"https://github.com/szapp/hydra-structlog","last_synced_at":"2026-05-28T17:30:48.365Z","repository":{"id":356399372,"uuid":"1195569628","full_name":"szapp/hydra-structlog","owner":"szapp","description":"An opinionated hydra plugin to configure logging with structlog","archived":false,"fork":false,"pushed_at":"2026-03-30T09:42:09.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-07T23:34:41.219Z","etag":null,"topics":["hydra","hydra-plugin","hydra-zen","plugin","structlog"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/hydra-structlog/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"ko_fi":"szapp"}},"created_at":"2026-03-29T20:19:38.000Z","updated_at":"2026-03-30T09:40:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/szapp/hydra-structlog","commit_stats":null,"previous_names":["szapp/hydra-structlog"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/szapp/hydra-structlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szapp%2Fhydra-structlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szapp%2Fhydra-structlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szapp%2Fhydra-structlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szapp%2Fhydra-structlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szapp","download_url":"https://codeload.github.com/szapp/hydra-structlog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szapp%2Fhydra-structlog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33619965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hydra","hydra-plugin","hydra-zen","plugin","structlog"],"created_at":"2026-05-28T17:30:46.013Z","updated_at":"2026-05-28T17:30:48.358Z","avatar_url":"https://github.com/szapp.png","language":"Python","funding_links":["https://ko-fi.com/szapp"],"categories":[],"sub_categories":[],"readme":"# Hydra-Structlog\n\n[![CI](https://github.com/szapp/hydra-structlog/actions/workflows/ci.yml/badge.svg)](https://github.com/szapp/hydra-structlog/actions/workflows/ci.yml)\n[![PyPI](https://img.shields.io/pypi/v/hydra-structlog)](https://pypi.python.org/pypi/hydra-structlog)\n[![Python Versions](https://img.shields.io/pypi/pyversions/hydra-structlog)](https://github.com/szapp/hydra-structlog)\n[![Support on Ko-fi](https://img.shields.io/badge/ko--fi-support-ff586e?logo=kofi\u0026logoColor=white)](https://ko-fi.com/szapp)\n\nAn opinionated hydra plugin to configure logging with structlog.\n\n## Usage\n\nStructlog is fully integrated in Hydra through a config group named `structlog` for `hydra.job_logging`.\n\n1. Install the plugin.\n\n    ```sh\n    uv add hydra-structlog\n    ```\n\n2. Override the job logging with a default in your config.\n\n    ```yaml\n    defaults:\n      - override hydra/job_logging=structlog\n    ```\n\n3. Hydra will now emit JSON logs (by default to `structured.log`) and print human readably logs to the console.\n\n## Customization\n\nStructlog comes configured with opinionated defaults.\n\nTo adjust the processors, use the hydra defaults as outlined above and overwrite individual config entries afterwards.\nFor example:\n\n```yaml\ndefaults:\n  - override hydra/job_logging=structlog\n\n# Change the storage location\nhydra:\n  job_logging:\n    handlers:\n      json:\n        filename: ${hydra.runtime.cwd}/logs/structured.log\n```\n\n## Defaults\n\nThe configuration runs structlog through the standard library logging.\nThat has several advantages.\n\nThe use of structlog and logging, e.g. by third-party packages, are recorded and both exhibit structlog's bound contextvars.\n\nThe processor chain is conveniently exposed in the job_logging configuration and adjustable through hydra's config interface.\n\nBecause lists are not easily manipulated in hydra configs, the processor chains are defined as dictionaries.\nThe name of each processor does not matter as long as its unique in the chain.\nThe default processor chain can then be extended more comfortably.\n\nTo remove a processor set it to `null`. See example below.\n\nBecause structlog's ProcessorFormatter does not accept the processors as strings, the logging config contains `_target_` instantiation.\n\n```yaml\ndefaults:\n  - override hydra/job_logging=structlog\n\n# Remove a processor from the default chain and add another one\nhydra:\n  job_logging:\n    formatters:\n      json:\n        foreign_pre_chain:\n          # Remove the add-log-level processor\n          add_logger_name: null\n          # Append a new processor\n          arbitrary_name:\n            # Follow hydra's instantiate syntax\n            _target_: structlog.stdlib.add_log_level_number\n            _partial_: true\n```\n\n## Notes\n\nPython 3.14 is currently not supported as `hydra.main` causes a ValueError on argparse-validation, see \u003chttps://github.com/facebookresearch/hydra/issues/3121\u003e.\nIt is recommended to use `hydra-zen` which does not have that problem and works well with Python 3.14.\n\nTracer injection is not implemented here as data science projects using hydra typically do not implement web apps.\nNevertheless, an appropriate structlog processor can be added to the job_logging config.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszapp%2Fhydra-structlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszapp%2Fhydra-structlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszapp%2Fhydra-structlog/lists"}