{"id":16392319,"url":"https://github.com/stefanbschneider/structlog-round","last_synced_at":"2025-06-22T07:02:46.062Z","repository":{"id":57471941,"uuid":"280239149","full_name":"stefanbschneider/structlog-round","owner":"stefanbschneider","description":"A light-weight structlog processor to round floats for prettier logging.","archived":false,"fork":false,"pushed_at":"2020-07-17T06:19:16.000Z","size":16,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-27T07:07:03.731Z","etag":null,"topics":["float","floating-point","logging","python","python3","round","structlog"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/structlog-round/","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/stefanbschneider.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-16T19:21:12.000Z","updated_at":"2022-12-02T21:46:04.000Z","dependencies_parsed_at":"2022-08-30T15:20:25.620Z","dependency_job_id":null,"html_url":"https://github.com/stefanbschneider/structlog-round","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/stefanbschneider/structlog-round","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanbschneider%2Fstructlog-round","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanbschneider%2Fstructlog-round/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanbschneider%2Fstructlog-round/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanbschneider%2Fstructlog-round/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanbschneider","download_url":"https://codeload.github.com/stefanbschneider/structlog-round/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanbschneider%2Fstructlog-round/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261250179,"owners_count":23130536,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["float","floating-point","logging","python","python3","round","structlog"],"created_at":"2024-10-11T04:49:35.782Z","updated_at":"2025-06-22T07:02:41.051Z","avatar_url":"https://github.com/stefanbschneider.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Python CI](https://github.com/stefanbschneider/structlog-round/workflows/Python%20CI/badge.svg?branch=master)\n\n# structlog-round\n\nA simple and light-weight [`structlog`](https://github.com/hynek/structlog) processor to round floats for prettier logging.\n\nAre you using `structlog` for convenient, structured logging in your Python program?\nLogging floats easily bloats your logs through many floating point digits?\n`structlog-round` rounds your floats for prettier logging but lets you keep full float precision inside your program.\n\nFor example:\n\n```python\nlog.msg(\"Hello world\", a=1/3, b=2/3, ab_list=[1/3, 2/3])\n\n# without structlog-round: prints long and ugly floats\n# 2020-07-16 21:48.21 Hello world        a=0.3333333333333333 b=0.6666666666666666 ab_list=[0.3333333333333333, 0.6666666666666666]\n\n# with structlog-round: floats are logged nicely rounded\n# 2020-07-16 21:48.21 Hello world        a=0.333 b=0.667 ab_list=[0.333, 0.667]\n```\n\n`structlog-round` lets you configure how floats are rounded and also supports rounding floats in (nested) lists, dicts, or `numpy` arrays.\n \n## Install\n\n```\npip install structlog-round\n```\n\nOr for development:\n\n```\ngit clone git@github.com:stefanbschneider/structlog-round.git\npython setup.py install\n# dependencies for testing\npip install -e .[dev]\n```\n\n## Usage\n\n```python\nimport structlog\nimport structlog_round\n\nstructlog.configure(\n    processors=[\n        # importing and adding FloatRounder to your list of processors is all you have to do\n        structlog_round.FloatRounder(digits=3),\n        structlog.dev.ConsoleRenderer()\n    ]\n)\nlog = structlog.get_logger()\n\na = 1/3\nb = 2/3\nlog.msg(\"Hello world\", a=a, b=b)\n# this log is easily readable with short, rounded floats\n# Hello world                    a=0.333 b=0.667\nprint(a, b)\n# the floats are still available in full precision and unrounded\n# 0.3333333333333333 0.6666666666666666\n```\n\n`FloatRounder` has the following configuration options:\n\n* `digits`: The number of digits to round to\n* `only_fields`: A list of only fields that should be rounded\n* `not_fields`: A list of fields that should not be rounded\n* `np_array_to_list` (bool): Whether to cast `numpy` arrays to lists and round floats for prettier logging\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanbschneider%2Fstructlog-round","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanbschneider%2Fstructlog-round","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanbschneider%2Fstructlog-round/lists"}